An R
package for graphics
part of the
tidyverse
developped by Hadley Wickham
June 7th, 2024
ggplot2
An R
package for graphics
part of the tidyverse
developped by Hadley Wickham
2 principles
a graph is made of several layers
grammar (i.e. mathematical & esthetical rules) between layers
[source: ggplot2 website]
Layer | Description |
---|---|
Data | data to be displayed |
Aesthetics | the variables that will be displayed |
Geometries | the way the data will be displayed |
ggplot
initialize the data
add (at least) one geometry — with +
specify required Aesthetics — with aes()
x
y
colour
fill
size
alpha
linetype
labels
shape
37 different geometries…
geom_point
geom_line
geom_tile
geom_bar
Chosing colors is hard ! (as hard as naming things ?)
Be mindful of:
black and white
colorblinds (~10% of white men)
➡️ viridis
🌐
➡️ MetBrewer
🌐
stop wasting time
ggplot2
practicalOpen BADAS4_practical.html
and follow along…
Google, Stack-overflow, GitHub, …