ggplot2 Layer Explorer
Toggle layers on and off; each colored block in the code is one layer of the plot
data: palmerpenguins::penguins
n ≈ 60 simulated obs.
Build Your Plot
Reset
Active layers
geom_violin()
shows the distribution shape
geom_point()
plots each observation as a dot
stat_summary()
adds a mean diamond per group
Layer order (drawn bottom → top):
violin → point
point → violin
Color
Fixed
Map to variable
🟣 purple
🟠 orange
species
sex
Color which geoms?
both
violins only
points only
Transparency (alpha)
0.2 (faint)
0.6 (medium)
1.0 (solid)
Where does
aes()
live?
aes()
tells ggplot which data columns control what you see (x-axis, y-axis, color…)
In ggplot() → global
In each layer → local
Appearance
Theme
default
minimal
classic
bw
Add
labs()
layer
Plot Preview
ggplot2 Code — paste into RStudio to run
Copy code
What just changed:
Code line colors
ggplot() base
geom_violin()
geom_point()
stat_summary()
theme
labels