1.

How to make multiple plots on to a single page layout in R? Explain with an example. 

Answer»

It is simple and easy to create multiple plots onto a SINGLE page using R. The following SYNTAX can be used to capture a 2 X 2 plot in a single page.

par(mfrow=c(2,2))

For example, if we want to display HISTOGRAM charts for IRIS dataset for various sepal and petal width and lengths, then each of the below COMMANDS will display one of the histogram charts on one page using R.

hist(iris$Sepal.Length) hist(iris$Sepal.Width) hist(iris$Petal.Length) hist(iris$Petal.Width)

Now if we use the command par(mfrow=c(2,2)) and then execute about code for plotting histogram, then four charts are displayed in a 2 X 2 format (2 rows with 2 columns). A sample representation of the result is shown in the below diagram.

Similarly, 3X3 representation can be displayed using SOMETHING like this - par(mfrow=c(3,3)) and so on.



Discussion

No Comment Found