2

I am using ggsave() to save plots from ggplot().

In R-Studio, clicking the "Zoom" button automatically resizes most of my plots to have quite aesthetic proportions, whereas when I try to manually specify the size and aspect ratios, I get plots that don't look as nice.

Is there a way that I can make ggsave use the same aspect ratio or size that R-Studio's "Zoom" button does?

Or how do I call the Zoom button using code?

enter image description here

RLave
  • 8,144
  • 3
  • 21
  • 37
Jeremy K.
  • 1,710
  • 14
  • 35

1 Answers1

4

If you right click on the zoomed image and select 'Inspect element', you'll see the aspect ratio there. That can then be passed into ggsave. Note that I'm assuming the aspect ratio selected by R Studio's zoom is constant on a given monitor in which case you would only need to find the aspect ratio once.

Here's an example of where to find it.

user71216
  • 65
  • 7