Using ggplot2

In the next few pages, you will see how to apply the principles of the The Grammar of Graphics with the ggplot2 package. With this package, you are able to change a lot of details in your graphics and create your own individual style. We will give you examples of some of its main settings.

Installing the ggplot2 package

You can find the ggplot2 package on CRAN, which makes it very easy to install it:


You are then able to simply load it with the following:


Or, you can just check the box in front of the package name in the packages pane of RStudio:

Installing the ggplot2 package

Qplot() and ggplot()

The ggplot2 package provides ...

Get Mastering RStudio – Develop, Communicate, and Collaborate with R 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.