In 1999, Leland Wilkinson published The Grammar of Graphics, a book that did for charts what linguistic grammar did for sentences: it gave you a system of composition instead of a closed list of templates. ggplot2 in R, Vega-Lite, Observable Plot, and Tableau's marks card are all direct descendants of his framework. Power BI's visualisation engine is the same idea, hidden behind clicks.
The seven layers
- Data: the dataset — rows and columns.
- Aesthetics: the mapping of data variables to visual properties (x, y, colour, size, shape, opacity).
- Geometries (geoms): the shapes that represent the data — points, lines, bars, areas.
- Statistics: any transformation applied — counts, means, regressions, density.
- Scales: how data values map to visual values (log axis, colour palette, size range).
- Coordinates: Cartesian, polar, geographic projections.
- Facets: small multiples — repeating the chart for sub-groups.
Composition over selection
Spreadsheet chart pickers give you 'Bar Chart', 'Pie Chart', 'Scatter'. The grammar of graphics says: there is no 'bar chart' — there is a geom_bar with x mapped to category and y mapped to count. Subtle change; massive consequences. You compose charts from primitives instead of choosing from a menu.
Try it now — Viz Studio playground
Open the LeadAfrik Viz Studio at /learn/viz-studio to feel this. Drag fields onto x, y, colour, size shelves; pick a mark type; the chart renders live. It runs entirely in your browser, on Kenya bank-rate, pension, and M-Pesa data. The same grammar transfers directly to Tableau and Power BI.
Why this matters even if you live in Power BI
Once you see the grammar, picking up a new tool takes a day, not a quarter. Tableau's 'marks card' is just aesthetics. Power BI's 'fields well' is just aesthetics. ggplot's aes() function is literally named for it. The mental model transfers. You stop being a Tableau expert or a Power BI expert and become someone who knows how charts compose, applied through whichever tool is in front of you.
# ggplot2 — the grammar made explicitlibrary(ggplot2)ggplot(data = sales,aes(x = quarter, y = revenue, colour = segment)) +geom_line(linewidth = 1) +geom_point(size = 3) +scale_colour_brewer(palette = "Set2") +facet_wrap(~ region) +labs(title = "Enterprise revenue grew 4x while SMB stayed flat")
The practical payoff
Once you think in grammar, decisions get cleaner. 'Should colour encode the segment or the product line?' becomes a real question with a real answer, not a vibe. 'Do I need facets or a single chart?' is a structural decision, not a design preference. You stop arguing about 'which chart type' and start arguing about the right mapping for the claim.
Exercise
Pick a chart you've made recently. Write it out in grammar-of-graphics terms: what is the data, the aesthetics (x, y, colour, size), the geom, any statistics applied, the scales, and any facets? Are any of the mappings doing unimportant work — and if so, can the chart be simpler?