Graphics with ggplot2
June 11, 2025
ggplot2An package for graphics
part of the tidyverse
originally developped by Hadley Wickham 🫶
a graph is made of several layers
grammar (i.e. mathematical & esthetical rules) between layers
7 components:
source: ggplot2 website
ggplot2 needs at least one of each of the three components below to make a plot:
| Component | Description |
|---|---|
| Data | data to be displayed |
| Mapping aesthetics | the variables that will be displayed |
| Geometry layers | the way the data will be displayed |
ggplotInitialize the data — through ggplot(data=...)
Add (at least) one geometry layer — through +geom_xxx()
specify required aesthetics mapping — through aes()
xycolourfillsizealphalinetypelabelsshapeMore than 37 different geometries available…
geom_pointgeom_linegeom_tilegeom_barWarning
Chosing colors is hard ! (as hard as naming things ?)
Be mindful of:
black & white (printing)
colorblinds (~10% of white men)
Tip
stop wasting time
Search engines, Large language Models chat-bots, Stack-overflow, GitHub, …
ggplot2 practical👉 Your turn !
Open SAVOR_practical4.html and follow along…