Skip to main content

Data Visualization

Plotting with ggplot2, including customizing themes and aesthetics, and creating interactive maps and tables with leaflet and DT.
data-visualization
tidyverse
lecture
intermediate
LearningLearning Objectives

After completing this session, you will be able to:

  • Describe the four essential components of a ggplot2::ggplot() call
  • Use theme and other functions to customize appealing data visualizations
  • Use facet_wrap() to create multiple related plots in one figure
  • Use ggplotly() to convert a static ggplot2 plot into an interactive visualization

1 Overview

ggplot2 is a popular package for visualizing data in R, designed to work seamlessly with the tidyverse ecosystem of packages. From the home page:

ggplot2 is a system for declaratively creating graphics, based on The Grammar of Graphics. You provide the data, tell ggplot2 how to map variables to aesthetics, what graphical primitives to use, and it takes care of the details.

The goal of this lesson is to explain the fundamentals of how ggplot2 work, introduce useful functions for customizing your plots, and inspire you to go and explore this awesome resource for visualizing your data.