Render intrinsic size plots at correct dpi - #1392
Merged
Merged
Conversation
thomasp85
approved these changes
Aug 19, 2026
thomasp85
left a comment
Collaborator
There was a problem hiding this comment.
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
Contributor
Author
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.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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
Bug Fixes
fig-width/fig-height) is in play (#15026).