Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Putting multiple plots in a A4 sheet by using R codes

Tags:

plot

r

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?

like image 924
Topdombili Avatar asked Jan 06 '13 16:01

Topdombili


People also ask

How do you make a panel on a graph in R?

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.


3 Answers

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()
like image 195
Josh O'Brien Avatar answered Nov 08 '22 04:11

Josh O'Brien


The layout function allows you to partition a single device (e.g. an A4 papge) into several areas that you can use for plots.

like image 23
Lars Kotthoff Avatar answered Nov 08 '22 03:11

Lars Kotthoff


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).

like image 43
Dieter Menne Avatar answered Nov 08 '22 03:11

Dieter Menne