# This document aims to show you how to:
# 1) Put multiple plots on one page
# 2) Save plots
# ----------------------------------------------------------------- #
# ---------------------- Multiple Plots --------------------------- #
# First a single plot; a line with slope .1
m = .1
x = .01 * (1:100)
plot( x, m*x, ylim=c(0,1) )
# Now for multiple plots
par(mfrow=c(3,3))
# this makes the next 9 plots you make appear on the same page
m = .1
x = .01 * (1:100)
for(i in 1:9){
plot( x, m*i*x, ylim=c(0,1) )
}
# There is also the function mfcol
par(mfcol=c(3,3))
# this makes the next 9 plots you make appear on the same page
m = .1
x = .01 * (1:100)
for(i in 1:9){
plot( x, m*i*x, ylim=c(0,1) )
}
# ----------------------------------------------------------------- #
# ---------------------- Saving Plots --------------------------- #
# Depending on your system, you may be able to click "save" when you have the plot you want.
# If your system doesn't allow this, or you are writing scripts to produce multiple graphics,
# you should use functions like pdf, png, ect. For details, see the corresponding help pages.
# Here is a simple example:
pdf(file = "boring_plot.pdf", width = 6, height = 12)
m = .1
x = .01 * (1:100)
plot( x, m*x, ylim=c(0,1) )
dev.off()
# Notice that no graph poped up, but that there is now a file "boring_plot.pdf" in your working directory.