R Studio export misses the plot and includes window and background of work area

This is the output of my RStudio export button. It has obviously missed the plotting area.

My example is a mermaid graph

graph LR
  A-->B
  A-->C
  C-->E
  B-->D
  C-->D
  D-->F
  E-->F

How would this happen? And how should I go about fixing it? Working on a mac book using Sierra 10.12.6

This only seems to happen when using a multi-monitor setup (which I do continuously), and also only when the RStudio window is in an 'attached' monitor (i.e. not the laptop screen).

Can you please provide a full set of code that we could run to attempt to reproduce this issue? (How is the plot from this mermaid graph generated?)

By using the content as a .mmd file executed in RStudio via pressing the preview. Then pressing the export button.

Thanks for clarifying. The preview looks fine for me with RStudio v1.1.419 on macOS 10.13.3:

Or is your point that the plot itself does not expand to fill the available plot area, if you increase the plot preview size? I can reproduce that, but that appears to be because a maximum width is enforced on the plot. It seems like this might be an issue in the DiagrammeR package itself, so you might want to report it to the package maintainer at Issues · rich-iannone/DiagrammeR · GitHub.

Thanks Kevin. My point is that the image above in my post is not a screen grab (print screen etc). That is the actual, physical file that is saved by the export button. I get to the same stage as your screen grab above, and then, on clicking save, the file that is generated is the one above.

Ahhhh, okay -- I understand now; sorry for being dense!

RStudio attempts to compute the screen position of the plot on the screen, and in doing that needs to know the screen's DPI. It seems like we're mis-computing the screen position in your case.

In your multi-monitor setup, what kind of displays are you using? Are they high-DPI displays, or regular DPI?

For what it's worth, I can reproduce this issue when I'm using my laptop's display (high DPI) alongside an external monitor (regular DPI). If my primary monitor is the regular DPI display, but I attempt to save the image while RStudio is on the laptop display, then the wrong portion of the screen is captured (like you describe).

1 Like