Hello there! Today, we will be learning how to make visualizations with R’s popular ggplot2 package. You can create simple visualizations with base R, but we are choosing to teach you ggplot2 because it is relatively easy to implement, well-documented, and supported by a community of data enthusiasts.

The ggplot2 package is part of the tidyverse so it comes equipped with other data cleaning and processing tools. The package is designed with the grammar of graphics in mind. This grammar of graphics describes a general pattern to follow when you’re creating visualization. In fact, that’s where the “gg” in ggplot comes from: grammar of graphics. ggplot2 has fostered a large programming community so you’ll find that as you forage into making your own plot outside of the Codecademy platform, there’ll be lots of resources and examples to welcome you.

This lesson will teach you the basic grammar required to create a plot. After you learn the underlying structure or “philosophy” of ggplot2, you can extend the logic to create many types of plots. Once you get the basic structure down, our upcoming lessons will explore how to customize your plot and calculate statistics in your visualization. Let’s get started.


Take a look at the image to the right. Observe how ggplot layers elements of the plot to create a final visualization. All plots start as a blank canvas with data associated to them. Layers of geometries, labels, and scales are then added to display the information. Click next when you’re ready to proceed!

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?