There are hundreds of named chart types — the bar, the line, the scatter, the bubble, the box, the violin — and learning them one by one, as a zoo of special cases, is a miserable way to live. In 1999 Leland Wilkinson proposed something far better in his book The Grammar of Graphics: don't memorise charts, learn the grammar that generates them. Just as a handful of grammatical rules produces endless sentences, a handful of graphical components produces endless charts. Hadley Wickham later turned this grammar into the wildly influential ggplot2, and its vocabulary now underlies visualisation everywhere.
The core idea: a chart is not a type, it is a recipe of composable layers. Change one layer and you get a different chart from the same data, deliberately rather than by rummaging through a menu.
Every statistical graphic is built by stacking a small set of independent components:
| Layer | What it does | Example |
|---|---|---|
| Data | The tidy table you are drawing. | One row per country-year |
| Aesthetic mappings | Which variable drives which visual channel: position, colour, size, shape. | x = income, y = lifespan, colour = continent, size = population |
| Geoms (geometries) | The marks that represent the rows. | point, line, bar, boxplot |
| Scales | How data values become pixels, colours, sizes; axes and legends. | log x-axis, a colour palette |
| Facets | Split the data into a grid of small multiples. | one panel per decade |
| Stats & coordinates | Transform data before drawing; choose the coordinate system. | bin into a histogram; polar coords |
The power is in the independence. A histogram and a bar chart share a geom (the bar) but differ in their stat (binning vs none); a scatter and a bubble chart share everything except that the bubble adds a size aesthetic. You are no longer choosing chart types — you are choosing mappings.
A
Read it as a sentence in the grammar: "map income to x, lifespan to y, region to colour, population to size, and draw the rows as points." That sentence is the chart. Swap "points" for "text" and you have a labelled plot; add a facet on region and the one panel becomes several. Nothing else changes.
The grammar frees you to choose, so choose on purpose. The geom should match the question, not your habit:
| Question | Natural geom |
|---|---|
| How is one variable distributed? | histogram / density |
| How do two numeric variables relate? | point (scatter) |
| How does a value change over time? | line |
| How do a few categories compare? | bar |
| How does a distribution differ across groups? | boxplot / violin |
Before the grammar of graphics, plotting software worked like a vending machine: press the "bar chart" button, get a bar chart, and pray it was what you wanted. Wilkinson's insight was that this hid the real structure. His grammar re-cast every chart as a formal composition of data, mappings, geoms, scales and facets — an idea so clean that Wickham's ggplot2 implementation became one of the most-used tools in all of statistics, and its "map variables to aesthetics" mental model was copied by Python's plotnine and Altair, by Tableau's "show me," and by the Vega-Lite grammar behind countless web charts. When you hear a data scientist say "map colour to species," they are speaking Wilkinson's grammar, usually without knowing whose it was.
A composable grammar makes it just as easy to build a dishonest chart as an honest one. Three classics to police in your own work:
The grammar gives you power; these are the responsibilities that come with it.
Kaggle Learn's free Data Visualization course has you build charts layer by layer — mapping variables to colour and shape, choosing the geom that fits the question, and avoiding the misleading-axis traps above — which is the grammar of graphics put straight into your hands.