Monday, April 18, 2016

Saving R plot to png

On Linux, if we want to save a plot to file we have to do specify before plotting to which file and in which format we want to work.

Say that I want to generate a PNG named myPlot.png in my current directory:
png('myPlot.png')
plot(df$var1, df$var2)
dev.off()
The last line says to R that I want to switch back to the default, meaning X11 that is going to show my up the result.

No comments:

Post a Comment