#Exporting plots in R studio #good website for this: https://danieljhocking.wordpress.com/2013/03/12/high-resolution-figures-in-r/ #lets see the plot x = 1:20 y = x * 2 p <- plot(x, y, type = "l") #plotting in PDF and TIFF forms pdf(file = "FileName.pdf", width = 12, height = 17, family = "Helvetica") # defaults to 7 x 7 inches plot(x,y,type="l") dev.off() #"device" off postscript("FileName.eps", width = 12, height = 17, horizontal = FALSE, onefile = FALSE, paper = "special", colormodel = "cmyk", family = "Courier") plot(x,y, type = "l") dev.off() bitmap("FileName.tiff", height = 12, width = 17, units = 'cm', type = "tifflzw", res = 300) plot(x,y,type="l") dev.off() tiff("FileName.tiff", height = 12, width = 17, units = 'cm', compression = "lzw", res = 300) plot(x,y,type="l") dev.off() png("FileName.png", height = 12, width = 17, units = "cm", res=300) plot(x,y,type="l", col = "red") dev.off() jpeg("FileName.jpg", height = 12, width = 17, units = "cm", res=300) plot(x,y,type="l") dev.off() #sometimes these commands have quirks. There are "optional" commands that sometimes need to be input for plots as you would expect. Basically, the "default" might not be what you want. Be prepared for some fiddling with the inputs. #we can do this in ggplot too library(ggplot2) qplot(x,y, geom="line") pdf(file = "FileNameGGplot.pdf", width = 12, height = 17, family = "Helvetica") # defaults to 7 x 7 inches qplot(x,y, geom="line") dev.off() #for more help with the basic codes, you can search in R studio or just type: ?png() #additional way to do it, with more control, is to build your plot within the source code for the function #basically, "function(file = "FileName.pdf", etc....)" #may be irritating ... but maintains the maximum resolution for any figure at any size.