date count package
3829 2025-06-25 54021 ggplot2
3830 2025-06-26 50323 ggplot2
3831 2025-06-27 50306 ggplot2
3832 2025-06-28 31488 ggplot2
3833 2025-06-29 33328 ggplot2
3834 2025-06-30 48941 ggplot2
The most popular data visualization framework in R
2025-07-23
ggplot2
is the most downloaded R library in the world
Part of the tidyverse
suite of packages, ggplot2
offers great consistency with dplyr
pipes and syntax 1
“gg” refers to “The Grammar of Graphics,” a 1999 book from Leland Wilkinson that provides a framework for creating statistical graphics in layered components
The “2” in ggplot2
alludes to the fact that this package supplants an older library simply called ggplot
, both developed by Hadley Wickham 2
Easy to start with some minimally viable code for a plot, but how does one make a cleaner and more polished graph?
By utilizing rest of the components, one can add more features to the graph and also clean up unnecessary elements
Implement some good data visualization practices 1
g6 <- ggplot(ggplot_downloads_df, # Data
aes(x = date, y = count)) + # Mapping
geom_point() + # Layer
geom_smooth() + # Layer (additional)
scale_y_continuous(
labels = label_number(
suffix = "K", scale = 1e-3)
) + # Scale
theme_minimal() + # Theme
labs(title = "ggplot2's rise in popularity over the past decade",
subtitle = "Number of daily downloads from CRAN",
x = NULL,
y = NULL) # Labels
g6
g7 <- ggplot(ggplot_downloads_df, # Data
aes(x = date, y = count)) + # Mapping
geom_point(colour = "lightgrey") + # Layer
geom_smooth() + # Layer (additional)
scale_y_continuous(
labels = label_number(
suffix = "K", scale = 1e-3)
) + # Scale
theme_minimal() + # Theme
labs(title = "ggplot2's rise in popularity over the past decade",
subtitle = "Number of daily downloads from CRAN",
x = NULL,
y = NULL) # Labels
g7
ggplot2
graphs in R Markdown/Quarto outputsggplot2
objects within Shiny appsggiraph
or ggplotly
packagesggplot2
with base R or different librariesOfficial website: https://ggplot2.tidyverse.org/index.html
Cheat sheet: https://github.com/rstudio/cheatsheets/blob/main/data-visualization.pdf
Book of common plots: https://r-graphics.org/
Example graphs (includes non-ggplot2
examples): https://r-graph-gallery.com/
Good data visualization practices by Stephanie Evergreen: https://www.datavisualizationchecklist.com/
Implementing Stephanie Evergreen checklist in ggplot2
: https://github.com/PHAC-RUG/presentations/blob/main/2021/ggplot_best_practices/data_viz_checklist.rmd
Link to this document (Quarto Markdown): https://github.com/PHAC-RUG/presentations/blob/main/2025/intro_ggplot2/intro_ggplot2.qmd
Link to this document (HTML): https://raw.githack.com/PHAC-RUG/presentations/main/2025/intro_ggplot2/intro_ggplot2.html