Stochastic Nonsense

Put something smart here.

Saving Plots in R -- Part 2 of a Series

This is post #02 in a running series about plotting in R.

Though the docs are relatively clear on how to save an R plot to disk in a variety of formats, I had some trouble figuring out how because I googled the wrong words. In the hope that this can help someone in the future, here’s how I generated the plots for the last post and saved them to disk:

1
2
3
4
5
png(filename='plot01.04.png', type='quartz')
plot(x=s$x, y=s$y, type='b', col='blue', xlim=c(20,30), ylim=c(6,10),
+ xlab='x in [20,30]', ylab='y in [6,10]', main='Basic Plotting Sample, Filtered')

dev.off()

It’s really as simple as using png or jpeg depending on your desired filetype.