library(ggplot2)
library(palmerpenguins)
ggplot(
data = penguins,
aes(x = bill_length_mm, y = bill_depth_mm)
) +
geom_point()
EE BIOL C177/C234
ggplot2ggplot2 provides a structured approach to visualizationggplot2
ggplot() β start a new plotdata = penguins β specify the datasetaes() β map variables to axes+ β add layers (like Photoshop!)geom_point() β draw pointsEvery plot has the same grammar:
Data β Aesthetics β Geometry = a plot!
The grey background wastes ink and looks bland. Use theme_bw():
Try theme_minimal(), theme_classic(), or packages like jtools:
Plot body_mass_g vs bill_depth_mm, colored by species:
ggplot2 uses the grammar of graphicscolor, shape, size, etc.Welcome to ggplot2