Skip to content

Report logical plot size in display_data metadata - #1387

Merged
seeM merged 3 commits into
mainfrom
feature/hidpi-plot-metadata
Aug 4, 2026
Merged

Report logical plot size in display_data metadata#1387
seeM merged 3 commits into
mainfrom
feature/hidpi-plot-metadata

Conversation

@seeM

@seeM seeM commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Addresses posit-dev/positron#15261.

Summary

Ark renders notebook plots at logical size × pixel ratio physical pixels. Previously, its display_data and update_display_data messages did not report the intended logical dimensions, so frontends could display a 2× render at twice its requested width and height.

This PR adds standard Jupyter PNG metadata containing the logical width and height:

{
  "image/png": {
    "width": "<logical width>",
    "height": "<logical height>"
  }
}

The PNG retains its higher physical resolution, while frontends—including Positron's Quarto inline-output renderer—display it at the requested logical size.

Screenshots

Before

Plot displayed at twice its intended size

After

Plot displayed at its intended logical size

QA

On a HiDPI display, enable inline output in a Quarto document and run:

#| fig-width: 4
#| fig-height: 3
plot(1:10)

The plot should:

  • display at 4 × 3 inches rather than 8 × 6 inches;
  • remain sharp at the display's native pixel ratio.

@seeM
seeM requested review from jmcphers and juliasilge and removed request for jmcphers August 3, 2026 17:55
@seeM
seeM requested a review from lionel- August 4, 2026 08:37

@lionel- lionel- left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thomasp85 might be interested in taking a look too

Comment thread crates/ark/src/plots/graphics_device.rs Outdated
@seeM
seeM removed the request for review from juliasilge August 4, 2026 13:49
@seeM
seeM force-pushed the feature/hidpi-plot-metadata branch from 8d451de to 8b9e742 Compare August 4, 2026 14:06
@seeM
seeM merged commit 8687e4d into main Aug 4, 2026
17 checks passed
@seeM
seeM deleted the feature/hidpi-plot-metadata branch August 4, 2026 14:33
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants