How to plot more than one plot in R?

r
ggplot2

#1

I am currently studying about plotting techniques in R while studying I came across one problem is that if I have more than one plot and I want to plot all the simultaneously how this can be done in R.

for example I have four plot
p1 = ggplot(…)
p2 = ggplot(…)
p3 = ggplot(…)
p4 = ggplot(…)

How to plot all these plots at a time.


#2

try par(mfrow=c(2,2))


#3

@harry

You can use par function.
Use par(mfrow=c(nrows,ncols))
You can choose any number of rows and columns. For 4 graphs, use either par(mfrow=c(1,4)) or par(mfrow=c(2,2))
Hope that helps. :slightly_smiling:


#4

Hi @harry

first check your version of ggplot2, with the new version (2.00) there is a problem if you use previous version take the package gridExtra and then function grid.arrange()
example
grid.arrange( p1,p2,p3,p4)

Hope this help.
Alain


#5

If you are looking to plot on the same data, then pairs might help.
Have a look at this link: