dataquerent
dataquerent

Reputation: 267

Is there a way to control the default pixel sizes of images exported from RStudio?

I am producing many images with R graphics.

I am using RStudio.

RStudio has "Save plot as Image" and "Save plot as PDF" options.

However, the default size of the plot window seems to be controlled by the interface. If I resize the windows and panes, the plot resizes, and sometimes loses important data.

Is there some environment variable that controls the default number of pixels in the plots?

Upvotes: 2

Views: 2701

Answers (1)

Drew Steen
Drew Steen

Reputation: 16607

USe the pdf, tiff, png, etc... devices. For instance

pdf("my_plot.pdf", height=6, width=8, units="in", res=300)
plot(mtcars$mpg, mtcars$cyl)
dev.off()

In this example, the image will be 300 x 6 pixels high and 300 x 8 pixels wide.

Upvotes: 3

Related Questions