You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Notebook plots rendered with an inconsistent size when devicePixelRatio > 0 (retina and other high-res monitors) #10825
The IDE will use the browser's devicePixelRatio for rendering Notebook plots to scale up the width/height and dpi (see my comments on this related issue: #7028).
But, the devicePixelRatio is not updated if the Plots plane is not visible or is zero width. This test here is checking the width and height of the plot's pane in the IDE. If one of them is 0, it won't set the size or the device pixel ratio. But we use the devicePixelRatio here to compute the image size to display when rendering a plot inline in an Rmd chunk. It has nothing to do with the plots pane size... so if the plots pane has never been made visible in this IDE session, the devicePixelRatio remains at the default of 1 and the notebook preview images are not scaled.
To reproduce, start the IDE on a retina display (or other monitor where the browser's window.devicePixelRatio > 1) with a layout where there's no plots pane visible in the initial setup. Render this chunk in an Rmd:
You should see it just less than 2" with a 96dpi screen.
Now just run this in the console to bring up the plots pane:
ggplot(mtcars, aes(mpg, wt)) + geom_point()
Now re-run the notebook chunk and see that it's 4X the size (8") (this assumes you are on a mac retina display). It would be 2X but we double-apply the scaling factor in that code linked above.
I think the fix for this particular bug is to always update the device pixel ration in set workbench metrics, even if the graphics device currently is zero width/height.
@timtmok , I think this is at least marginally related to other plot resolution / sizing issues you've been dealing with. If you think it's related and/or can easily fix it, we should try to address in SW.
I'll see what I can do. It's definitely in a different area of the code if Jeff's suggestion is the solution. There might be something in the GWT side to get the DPI but it appears that Jeff has pointed out that it's available in CPP and should be handled there to render the plot.
Activity
mikebessuille commentedon Mar 31, 2022
@timtmok , I think this is at least marginally related to other plot resolution / sizing issues you've been dealing with. If you think it's related and/or can easily fix it, we should try to address in SW.
timtmok commentedon Mar 31, 2022
I'll see what I can do. It's definitely in a different area of the code if Jeff's suggestion is the solution. There might be something in the GWT side to get the DPI but it appears that Jeff has pointed out that it's available in CPP and should be handled there to render the plot.
mikebessuille commentedon Mar 31, 2022
In that case I'm moving it to next release.
netique commentedon Sep 23, 2022
Consider also issue #4521.
ronblum commentedon Dec 2, 2022
Moving to Cherry Blossom, in order to verify that it's fixed by PR #12324. If it's not, we'll reassign it to the current milestone.
jonvanausdeln commentedon Feb 6, 2023
Verified on 2023.03.0-daily+280. The sizes appear to be correct on hi-resolution monitors.