← R Programming learning path
R Programming · Module 5 of 10

Visualisation with ggplot2

Create beautiful charts using the grammar of graphics.

📖 Key ideas

  1. ggplot(df, aes(x = age, y = salary)) sets data and mappings.
  2. Add geoms: geom_point(), geom_line(), geom_bar(), geom_histogram().
  3. Add layers with +.
  4. labs() sets titles; theme_minimal() changes style.
  5. facet_wrap() makes small multiples.
💡 Real-life example: ggplot2 is building a chart like a sandwich: bread (data), filling (geoms), sauce (themes), layer by layer.
ggplot()Starts a plot
aes()Maps data to visual properties
geomGeometric layer like points or bars
facet_wrapSplits into panels