← R Programming learning pathR Programming · Module 5 of 10
Visualisation with ggplot2
Create beautiful charts using the grammar of graphics.
📖 Key ideas
- ggplot(df, aes(x = age, y = salary)) sets data and mappings.
- Add geoms: geom_point(), geom_line(), geom_bar(), geom_histogram().
- Add layers with +.
- labs() sets titles; theme_minimal() changes style.
- 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