Wrap up
Now that we have gotten a first taste of the ggsql syntax, let’s return to the grammar of graphics overview from before and see how it all relates together.
You may see that there is not a 1-to-1 mapping between the grammar components and the clauses we have introduced. This is because some of the core concepts belong to the same (or multiple) parts of the syntax. Good syntax design is not to just blindly take a theoretical foundation and translate it into code, but figure out how it relates best to ergonomic coding units. This was the reason for the success of ggplot2 and we proudly follow in that footstep.
From grammar to syntax
To help you in your further learning, we provide an overview of where the different grammar components fit into the ggsql syntax. Use this as a reference when you explore the full documentation.
| Grammar | Syntax |
|---|---|
| Data | Data can be specified in several places:
|
| Mappings | Mappings also exist in multiple places in the syntax
|
| Statistics | Statistics are implicitly part of the layer created with DRAW. Each layer has their own statistics transformation hard-wired. |
| Scales | ggsql provides default scales as needed, but these can be overridden with the SCALE clause. |
| Geometries | Geometries are inherent to the layers created with DRAW and PLACE. Each layer has a specific geometry and some layers may share the same geometry (e.g. histogram and bar). |
| Facets | Facets are created with the FACET clause. The default facet creates a single view showing all the data. |
| Coordinates | Coordinate systems are defined using PROJECT but can also be derived from the mapping. If you map to x and y, ggsql knows you are using a Cartesian coordinate system and if you map to angle and radius it knows you want a polar coordinate system. |
| Theme | Currently not supported. |