4.10 All other types of plots

In this chapter we have introduced some of the most common geoms, as well as explained how ggplot() works. In fact, ggplot has 56 different geoms for you to use; see its documentation for a full list: https://ggplot2.tidyverse.org.

With the ability of combining multiple geoms together on the same plot, the possibilities really are endless. Furthermore, the plotly Graphic Library (https://plot.ly/ggplot2/) can make some of your ggplots interactive, meaning you can use your mouse to hover over the point or zoom and subset interactively.

The two most important things to understand about ggplot() are:

  • Variables (columns in your dataset) need to be inside aes();
  • aes() can be both at the top - data %>% ggplot(aes()) - as well as inside a geom (e.g., geom_point(aes())). This distinction is useful when combining multiple geoms. All your geoms will “know about” the top-level aes() variables, but including aes() variables inside a specific geom means it only applies to that one.