Is it possible to change the default image size when exporting a plot to a file or clipboard? I haven't been able to find a setting.
Here's how to save a ggplot graph to an image file where you specify the image size (and resolution). This also works with SVG format, and graphs from the other R plotting systems (base, lattice).
library(ggplot2) p1 <- ggplot(data=mtcars, aes(x=disp, y=mpg)) + geom_point() + geom_smooth() p1 ggsave("my_graph_1.png", plot=p1, height=6, width=8, units=c("cm"), dpi=600) # PNG format # 4800 pixels/600 dpi = 8 inches png(file="my_graph_2.png", res=600, width=4800, height=4800, pointsize=10, type="windows", antialias="cleartype") p1 dev.off() # JPG format jpeg(file="my_graph_3.jpg", res=600, width=4800, height=4800, pointsize=10, type="windows", antialias="cleartype") p1 dev.off()
As image size increases you may need to adjust other graphics elements (e.g. symbol size) to get the result you want.
Yes, thanks. I should have said that I know how to do it with code, but one of the reasons for using RStudio is the GUI.
So is there a way to change this setting within the app? If not, there should be.
Have you looked at the export button in the viewer pane?
The dimensions of the plot in RStudio's plot pane are the dimensions of the plot pane. For example, if the plot that appears in the plot pane is 600 by 600 pixels, when you click to export, it'll offer an image that's 600 by 600 pixels. If you readjust the dimensions of the plot pane to 400 * 200 and then export, the exported image will have those new 400 * 200 dimensions.
If you'd like a different size image, you'll either need to adjust the dimension in the plot export GUI, or export it via code.
Thanks. This answers the question about how the default size is set when exporting. I still wish this was a setting.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
That's what I'm using.
So what's the problem?