Section 36 Save the graphics

36.1 R Graphics Devices

Device Explanation
pdf Writes PDF graphics commands to a file
postscript Writes PostScript graphics commands to a file
bitmap Prepares bitmap pseudo-device via Ghostscript (if available).
svg SVG device based on cairo graphics.
png PNG bitmap device
jpeg JPEG bitmap device
bmp BMP bitmap device
tiff TIFF bitmap device

36.2 Save as a png file

data(mtcars)

?png

png(file='test.png')

pairs(mtcars[,c(1:4)],
         main='Scatter Plot',
         cex = 1.5, pch = 24, bg = "light blue")

dev.off()

36.3 Save as a pdf file

?pdf

pdf(file='test.pdf')

pairs(mtcars[,c(1:4)],
         main='Scatter Plot',
         cex = 1.5, pch = 24, bg = "light blue")

pairs(iris, col = 'blue')

dev.off()