R par() code example

Example 1: change how many plots you view r

par(mfrow=c(2,2))

Example 2: par in r

par(mfrow=c(1,1))

# make labels and margins smaller
par(cex=0.7, mai=c(0.1,0.1,0.2,0.1))

# define area for the plot
par(fig=c(0.1,0.7,0.3,0.9))

# define area for the boxplot
par(fig=c(0.8,1,0,1), new=TRUE)

Example 3: plot multiple plots in r

# One figure in row 1 and two figures in row 2
# row 1 is 1/3 the height of row 2
# column 2 is 1/4 the width of the column 1
attach(mtcars)
layout(matrix(c(1,1,2,3), 2, 2, byrow = TRUE),
   widths=c(3,1), heights=c(1,2))
hist(wt)
hist(mpg)
hist(disp)