Repository navigation
Conversation
|
Another issue tightly connected with inline plot display is that with This has to be changed on java/cpp side. Unfortunately, I cannot build RStudio from source on macOS Ventura (I really cannot replicate the build environment, neither wikis nor INSTALL helped me, so that holds me back...). |
|
Thank you for the contribution! I'll take a look at the changes this week. The current release has reached a point where only critical fixes will be merged. After review, it will be merged once there's a branch for next release. |
|
For testing purposes, we will probably want to choose one or more of the referenced issues to move into test, once this is merged. |
d6c86e0 to
77ef58d
Compare
|
Jackie has created PR #12350 to get this change rebased on |
Reopen Fix notebook plots scaling on non-zero pixel ratio devices, remove margins (#12324)
|
Thanks @netique, this has been merged. |
|
@jgutman, @timtmok maybe you can close all of these now: #4521, #2098, #10825, #7028, #4913, rstudio/rmarkdown#2262, rstudio/rmarkdown#1827. But maybe I would be happy if the people commenting on those could try out the fix first – it's now available in the daily builds. |
|
@netique Thank you so much for fixing this! I moved all of the issues that this resolves to Cherry Blossom so that we can verify that all of the issues are fixed. If any aren't, we'll switch them back to the former milestone, but hopefully they can all be closed. Thanks again! |

Intent
The PR attempts to resolve several issues pertaining wrong scaling of inline plots preview (also known as notebook plots). A tentative list of issues is as follows: #4521, #2098, #10825, #7028, #4913, rstudio/rmarkdown#2262, rstudio/rmarkdown#1827.
Approach
In
NotebookPlots.cpp, a temporary device with a set of arguments is created withsetNotebookGraphicsOptionfunction living in the R moduleNotebookPlots.R. The device itself is created by another function defined herein –createNotebookGraphicsDevice. There are two situations to consider:fig.widthand/orfig.heightchunk options are not set and the preview resizes to fit the editor (automatic size behaviour in the source code lingo). In this case, the width is provided fromace_contentgetOffsetWidthand comes in pixels (height is calculated using the golden ratio, but the width is cut by 22 pixels to account for padding beforehand). So, the dimensions and theresis multiplied by a device pixel ratio to look the same on different DPIs (the PR does not touch this).To illustrate, here are two
pngplots with the same dimensions in inches, but vastly different DPI. Note that the appearance and physical dimensions do not change:Note that in this PR I made additional edit concerning figure margins. These were manually edited by
setNotebookMarginsfunction "called" insetNotebookGraphicsOption. I believe this margin manipulation is unwanted because it makes the actual plot different from the same plot in the rendered document. However, it may be retained for the situation 1.Automated Tests
There are no tests provided.
QA Notes
As the changes introduced affect the very end of the "pipeline" creating the inline plot preview, I believe there is only this very thing to check. However, there is
replayNotebookPlotsfunction that calls the edited portions of code.Checklist
NEWS.md