Save Multiple Plots to Same Page in PDF

To save multiple plots to the same page in the PDF file, we use the par() function to create a grid and then add plots to the grid. In this way, all the plots are saved on the same page of the pdf file. We use the mfrow argument to the par() function to create the desired grid.

Syntax:

par( mfrow )

where, 

  • mfrow: determines the vector that contains the number of rows and columns for the grid.

Example:

Here, is a program to save 4 plots in a 2X2 grid on the same page of a pdf file.

R




# Open pdf file
pdf(file= "sample.pdf" )
  
# create a 2X2 grid
par( mfrow= c(2,2) )
  
# draw plots
plot(1:10)
plot(1:20)
plot(1:30)
plot(1:40)


Output:


How to Export Multiple Plots to PDF in R?

In this article, we will learn how to export multiple plots to a PDF in the R Programming Language.

Similar Reads

Save Multiple plots on different pages on PDF file:

To save multiple plots in pdf we use the pdf() function to create and open a pdf file in the R Language....

Save Multiple Plots to Same Page in PDF:

...