Skip to content

Render intrinsic size plots at correct dpi - #1392

Merged
jmcphers merged 1 commit into
mainfrom
bugfix/quarto-intrinsic-dpi
Aug 19, 2026
Merged

Render intrinsic size plots at correct dpi#1392
jmcphers merged 1 commit into
mainfrom
bugfix/quarto-intrinsic-dpi

Conversation

@jmcphers

@jmcphers jmcphers commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Intent

Fixes plots rendered at intrinsic size looking pixelated and saving at low resolution when a Quarto figure size (fig-width/fig-height) is in play.

Addresses posit-dev/positron#15026.

Approach

A Quarto figure size is a physical size in inches. When the plot pane asks for the plot at its intrinsic size, we were converting those inches to pixels at the screen's base DPI (72 on Linux, 96 on macOS) and only scaling further by the display's pixel ratio. On an ordinary (non-HiDPI) display that left a 4x2 inch plot at just 288x144 pixels, so it looked blurry when the pane stretched it to fit, and it saved at that same low resolution. Quarto renders the same plot at 768x384.

The pixel ratio is really two things rolled into one: how dense the display is, and how sharp we render. For a physical-inch plot that the pane will scale up, tying sharpness to the display alone isn't enough.

So when rendering an inch-based intrinsic size, we now raise the effective pixel ratio to reach a target resolution of 192 DPI, matching Quarto's default (its 96 DPI figures at 2x retina). This is a floor: displays that already exceed it are left alone, and pixel-based intrinsic sizes (such as Matplotlib's) keep their own resolution. As a result a 4x2 inch plot now renders at least 768x384 on every OS.

image

A small companion change rounds device dimensions to whole pixels, since the new floor can produce a fractional pixel ratio.

Testing

Adds an integration test that creates a Quarto-sized plot and sends the same intrinsic render request the plot pane sends when "intrinsic" is selected, then checks the resulting PNG is 768x384. It fails before this change and passes after.

Positron Release Notes

New Features

  • N/A

Bug Fixes

  • Fixes plots rendered at intrinsic size looking pixelated and saving at low resolution when a Quarto figure size (fig-width/fig-height) is in play (#15026).

@jmcphers jmcphers changed the title render intrinsic size plots at correct dpi Render intrinsic size plots at correct dpi Aug 19, 2026
@jmcphers
jmcphers requested a review from thomasp85 August 19, 2026 00:45

@thomasp85 thomasp85 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This generally LGTM

One question is whether a user setting a dpi option explicitly should have this honoured, even if it's below the target resolution? Since dpi drives how absolute sizing (font-size, line width, point size) is relative to relative sizes, I expect a user setting this value wants the output to honor it so that they can expect the same relative look as they get when rendering the markdown

@jmcphers

Copy link
Copy Markdown
Contributor Author

One question is whether a user setting a dpi option explicitly should have this honoured

Seems reasonable! Can you open an issue for that and name the specific DPI option(s) you were thinking of? (not sure if you're thinking R level, Ark level, Quarto level, etc.)

@jmcphers
jmcphers merged commit 30d86d3 into main Aug 19, 2026
17 checks passed
@jmcphers
jmcphers deleted the bugfix/quarto-intrinsic-dpi branch August 19, 2026 14:35
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 19, 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