The easy way is to use the multiplot function to put multiple graphs on one page, defined at the bottom of this page. If it isn’t suitable for your needs, you can copy and modify it.

## Problem

You want to put multiple graphs on one page.

## Solution-1

use the multiplot function

### plots and store

First, set up the plots and store them, but don’t render them yet. The details of these plots aren’t important; all you need to do is store the plot objects in variables.

1 | library(ggplot2) |

### multiplot function

This is the definition of multiplot. It can take any number of plot objects as arguments, or if it can take a list of plot objects passed to plotlist.

1 | # Multiple plot function |

### multiplot

Once the plot objects are set up, we can render them with multiplot. This will make two columns of graphs:

1 | multiplot(p1, p2, p3, p4, cols=2) |

## Solution-2

facet_grid

1 | p <- ggplot(mtcars, aes(mpg, wt)) + geom_point() |

1 | # With two variables |

## Solution-3

grid.arrange

1 | library(gridExtra) |