Appendix A — The kernel card
The whole grammar, on one page. The functions around it are in Functions around the grammar. This card is extracted live from The kernel as the book builds, so it cannot disagree with the chapter it comes from.
| Kind | The words |
|---|---|
| Sources | data query |
| Marks | point line area bar step interval box ribbon text path rule zone surface edge |
| Channels | x y z color size shape pattern opacity group label play |
| Transforms | bin smooth count density proportion sum mean median max min quantile range confidence deviation bounds partition flow layout cluster, and the four collision modifiers, dodge stack jitter repel |
| Operators | + layers, * derives, | and / arrange |
| Scales | linear log time category order |
| Spaces | flat space polar nest map globe network |
| Settings | style theme palette |
| Labels | title x_label y_label z_label |
| Facets | facet |
| Selections | brush |
The minimum sentence is a source, a mark, and the mark’s required position channels:
data(table) + mark + x(column) + y(column)
The order of + is a convention, not a rule: every sentence in this book reads left to right as data, mark, positions, refinements. A channel written before any mark is shared by every layer that can accept it; written after a mark, it belongs to that mark alone. Each later data() applies to the next mark.
Deriving is what * does: it puts a transform on a mark, and the mark is always on the left. Two transforms are written in the order they happen: bar * bin * mean cuts the axis into bands, then averages inside each.
Precedence decides what groups first: *, then /, then +, then |. A single plot then needs no parentheses; a page of plots does. data(t) + bar * bin + x(a) | facet(g) derives the mark, builds the plot, then splits it.
When gog refuses, the message names the rule and the fix. Illegal means the grammar forbids it: rewrite. Unsupported means the engine does not draw it: write it another way. A warning means gog drew the plot and something is worth checking: read it and decide.