I have 6 number of plots in R and I wanted to plot them in a single view. In other words , I want to put them in a single page in A4 size.
The plot code I am using is:
plot(temp$ambtemp,type="o", pch=22, lty=2, col="brown",xlab = "Hour 2007/09/30" , ylab= "Tempreture" )
title(main="Hourly Mean, node 25", col.main="brown", font.main=1)
Any suggestion?
To create Multi Panel Plots in the R Language, we first divide the plot frame into the desired number of rows and columns and then fill those with desired plots. To divide the plot frame into the desired number of rows and columns, we use the par() function of the R Language.
Here's a reproducible example of how you might do this:
pdf('eg.pdf', width = 8.3, height = 11.7) ## Device with dimensions of A4 paper
par(omi = rep(.5, 4)) ## 1/2 inch outer margins
par(mfrow = c(3,2)) ## 2x3 grid of plotting areas
replicate(plot(rnorm(99)), n = 6) ## 6 example plots
dev.off()
The layout
function allows you to partition a single device (e.g. an A4 papge) into several areas that you can use for plots.
The simplest way if you use standard graphics is with par(mfrow=c(3,2))
. Nothing else needed.
However, I strongly recommend having a look at lattice
or ggplot2
graphics if you want to make really nice multi-panel plot (which is also the answer to you last question).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With