# How To Plot With Patchwork: Exercises

**R-exercises**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

**INTRODUCTION**

The goal of patchwork is to make it simple to combine separate ggplots into the same graphic. It tries to solve the same problem as gridExtra::grid.arrange() and cowplot::plot_grid, but using an API that incites exploration and iteration.

Before proceeding, please follow our short tutorial.

Look at the examples given and try to understand the logic behind them. Then, try to solve the exercises below by using R without looking at the answers. Then, check the solutions to check your answers.

**Exercise 1**

Create a scatter-plot object of `mtcars`

between `mpg`

and `disp`

.

**Exercise 2**

Create a box-plot object of `mtcars`

between `gear`

and `disp`

grouped by `gear`

.

**Exercise 3**

Compose those two objects into one graph.

**Exercise 4**

Repeat the previous process but in one plotting operation.

**Exercise 5**

Display the composed graph in one column with the two graphs, one below the other.

**Exercise 6**

Set the graph on top to have two times the size of the graph at the bottom.

**Exercise 7**

Add space between your plots.

**Exercise 8**

Create two objects of your choice (`p3`

,` p4`

) and display all of your four objects in nested mode by putting `p4`

on top` p1`

and `p2`

and `p3`

at the bottom (nested one below the other.)

**Exercise 9**

Now, put the two nested plots next to each other.

**Exercise 10**

Finally, display `p4`

in one column and the rest of your objects in another.

**leave a comment**for the author, please follow the link and comment on their blog:

**R-exercises**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.