save png plot in r code example

Example 1: how to save plots in r

jpeg(file="saving_plot1.jpeg")
hist(Temperature, col="darkgreen")
dev.off()

png(file="C:/Datamentor/R-tutorial/saving_plot2.png",
width=600, height=350)
hist(Temperature, col="gold")
dev.off()

bmp(file="saving_plot3.bmp",
width=6, height=4, units="in", res=100)
hist(Temperature, col="steelblue")
dev.off()

tiff(file="saving_plot3.tiff",
width=6, height=4, units="in", res=100)
hist(Temperature, col="steelblue")
dev.off()

pdf(file="saving_plot4.pdf")
hist(Temperature, col="violet")
dev.off()

postscript(file="saving_plot4.ps")
hist(Temperature, col="violet")
dev.off()

Example 2: how to save plots into raster format from r

tiff(file="saving_plot3.tiff",
width=6, height=4, units="in", res=100)
hist(Temperature, col="steelblue")
dev.off()