Skip to main content

Menu

LEVEL 0
0/5 XP
HomeAboutTopicsPricingMy VaultStats

Categories

πŸ€– Artificial Intelligence
☁️ Cloud and Infrastructure
πŸ’Ύ Data and Databases
πŸ’Ό Professional Skills
🎯 Programming and Development
πŸ”’ Security and Networking
πŸ“š Specialized Topics
HomeAboutTopicsPricingMy VaultStats
LEVEL 0
0/5 XP
GitHub
Β© 2026 CheatGridβ„’. All rights reserved.
Privacy PolicyTerms of UseAboutContact

ggplot2 Cheat Sheet

ggplot2 Cheat Sheet

Back to Data Science
Updated 2026-04-27
Next Topic: Gradio ML Demo and App Framework Cheat Sheet

ggplot2 is R's most powerful data visualization package, built on the Grammar of Graphicsβ€”a systematic framework that treats plots as compositions of independent layers (data, aesthetics, geometries, statistics, scales, coordinates, and facets). Originally created by Hadley Wickham, ggplot2 is now the industry standard for publication-quality graphics in R, deeply integrated into the tidyverse ecosystem. Unlike base R plotting, which describes what to draw, ggplot2 describes how variables map to visual properties, enabling you to build complex visualizations incrementally. The key mental model: every plot is a layered combination of components added with +, where swapping one layer (e.g., geom_point() for geom_line()) transforms the visualization without rewriting the entire plot. As of version 4.0.0 (2025), ggplot2 uses an S7 backend and introduces element_geom() for controlling geom appearance through the theme system.


What This Cheat Sheet Covers

This topic spans 21 focused tables and 202 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.

Table 1: Core Building BlocksTable 2: Geoms for Points and LinesTable 3: Geoms for Distributions and UncertaintyTable 4: Geoms for Categorical, Bar, and Grid DataTable 5: Geoms for Text and AnnotationsTable 6: Geoms for Spatial DataTable 7: Statistical TransformationsTable 8: Position AdjustmentsTable 9: Coordinate SystemsTable 10: Faceting for Small MultiplesTable 11: Scale Functions for AxesTable 12: Color and Fill ScalesTable 13: Other Aesthetic ScalesTable 14: Built-in ThemesTable 15: Theme Elements for CustomizationTable 16: Common Theme ArgumentsTable 17: Legends and GuidesTable 18: Advanced TechniquesTable 19: Plot Composition and ArrangementTable 20: Saving and ExportTable 21: Extension Packages

Table 1: Core Building Blocks

ComponentExampleDescription
ggplot()
ggplot(data = df, aes(x, y))
β€’ Initializes a plot object
β€’ specifies data and global aesthetic mappings inherited by all layers.
aes()
aes(x = mpg, y = hp, color = cyl)
β€’ Maps variables to aesthetics (x, y, color, fill, size, shape, alpha, linetype)
β€’ placed in ggplot() for global or in geom_*() for layer-specific.
geom_*()
geom_point()
geom_line()
β€’ Defines the geometric object (visual representation)
β€’ each geom creates a new layer.
stat_*()
stat_summary(fun = mean)
β€’ Applies statistical transformation before plotting
β€’ every geom has a default stat (e.g., geom_bar() uses stat_count()).
scale_*()
scale_x_continuous()
scale_color_manual()
β€’ Controls how data values map to visual properties
β€’ customizes axes, colors, sizes, limits, labels, and transformations.

More in Data Science

  • GeoPandas Cheat Sheet
  • Gradio ML Demo and App Framework Cheat Sheet
  • AB Testing and Online Experimentation Cheat Sheet
  • Design of Experiments (DOE) Cheat Sheet
  • OpenRefine Cheat Sheet
  • SciPy Cheat Sheet
View all 47 topics in Data Science