# Saving a plot created in R as TIFF at high resolution # https://www.datamentor.io/r-programming/saving-plot # In base R: tiff(file="plot_tiff.tiff", width=15, height=10, units="cm", res=600) # change the dimensions and resolution as needed boxplot(iris[-5], col = "orchid2", border = "red") # The plot you want to generate and save (which will not appear on the screen) dev.off() # Device off (will save the plot to a file and the plot will appear on the screen) # If you are using ggplot2: # https://stackoverflow.com/questions/38907514/saving-a-high-resolution-image-in-r #using ggsave library("ggplot2") ggplot(aes(Sepal.Length, Sepal.Width), data = iris) + geom_point() + geom_smooth(method=lm, fill = NA, fullrange=TRUE, color = "orchid") ggsave("iris1.tiff", units="in", width=5, height=4, dpi=300, compression = 'lzw') #using tiff() and dev.off tiff('iris2.tiff', units="in", width=5, height=4, res=300, compression = 'lzw') ggplot(aes(Sepal.Length, Sepal.Width), data = iris) + geom_point() + geom_smooth(method=lm, fill = NA, fullrange=TRUE, color = "orchid") dev.off() # An example script from https://aghaynes.wordpress.com/2018/05/26/graphics_tips: # tiff("~/Manuscript/Figs/Fig1.tiff", width = 2, height = 2, units = "in", res = 600) # plot(dist ~ speed, cars) # cars is a base R dataset - data(cars) # dev.off() # See also: https://aghaynes.wordpress.com/2018/05/26/graphics_tips # See also: https://www.r-bloggers.com/high-resolution-figures-in-r # See also: Cookbook for R - Output to a File: http://www.cookbook-r.com/Graphs/Output_to_a_file