VISUALISE FROM ggsql:airquality
DRAW ribbon
MAPPING Date AS x, Wind AS ymin, Temp AS ymaxRibbon
Layers are declared with the
DRAWclause. Read the documentation for this clause for a thorough description of how to use it.
The ribbon layer is used to display extrema over a sorted x-axis. It can be seen as an area chart that is unanchored from zero.
Aesthetics
The following aesthetics are recognised by the ribbon layer.
Required
x: Position along the x-axisymin: Lower position along the y-axis.ymax: Upper position along the y-axis.
Optional
stroke: The colour of the contour lines.fill: The colour of the inner area.colour: Shorthand for settingstrokeandfillsimultaneously.opacity: The opacity of the colours.linewidth: The width of the contour lines.
Settings
position: Determines the position adjustment to use for the layer (default is'identity')
Data transformation
The ribbon layer does not transform its data but passes it through unchanged.
Examples
A ribbon plot with arbitrary values as minima/maxima
Ribbon plots are great for showing the range of some aggregation.
// Weekly aggregation of temperature
SELECT
WEEKOFYEAR(Date) AS Week,
MAX(Temp) AS MaxTemp,
MEAN(Temp) AS MeanTemp,
MIN(Temp) AS MinTemp
FROM ggsql:airquality
GROUP BY WEEKOFYEAR(Date)
VISUALISE Week AS x
DRAW ribbon
MAPPING MinTemp AS ymin, MaxTemp AS ymax
SETTING opacity => 0.5
DRAW line
MAPPING MeanTemp AS y