Creating multiple plot matrix layouts

In this recipe, you will learn how to present more than one graph in a single image. Pairs plots are one example, which we saw in the last recipe, but here, you will learn how to include different types of graphs in each cell of a graph matrix.

How to do it...

Let's say we want to make a 2 x 3 matrix of graphs, made of two rows and three columns of graphs. We use the par() command as follows:

par(mfrow=c(2,3))
plot(rnorm(100),col="blue",main="Plot No.1")
plot(rnorm(100),col="blue",main="Plot No.2")
plot(rnorm(100),col="green",main="Plot No.3")
plot(rnorm(100),col="black",main="Plot No.4")
plot(rnorm(100),col="green",main="Plot No.5")
plot(rnorm(100),col="orange",main="Plot No.6")

How it works...

The par() command ...

Get R: Data Analysis and Visualization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.