Topdombili
Topdombili

Reputation: 255

Putting multiple plots in a A4 sheet by using R codes

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?

Upvotes: 5

Views: 4531

Answers (3)

Josh O'Brien
Josh O'Brien

Reputation: 162351

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

Upvotes: 8

Dieter Menne
Dieter Menne

Reputation: 10215

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

Upvotes: 2

Lars Kotthoff
Lars Kotthoff

Reputation: 109242

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

Upvotes: 3

Related Questions