You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/syntax/clause/draw.qmd
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -98,3 +98,6 @@ ORDER BY <column>, ...
98
98
```
99
99
100
100
For some layers the order of records in the data is important, e.g. the path layer which connect records in the order they are provided. Since databases often doesn't guarantee a specific order of the data, the `ORDER BY` clause can be used to enforce such and order. Even for layers where the order doesn't immediately seem to matter it may have an effect, e.g. an overplottet scatterplot where the records in the end of the data are plottet on top of the one in the start.
101
+
102
+
## Layer orientation
103
+
Some layer types treat the two axes differently. For instance, a boxplot has categories along a discrete axis and summary statistics along a continuous one. While we are used to seeing boxplots with categories along the x-axis, this is not a necessity. The orientation can be deduced directly from the mappings in the layer. So, if you map discrete data to the x axis and continuous data to the y axis you get a boxplot in the standard orientation, whereas if you switch the mapping the boxes will "lay down" instead. The vast majority of layers that have an orientation also have a unique mapping pattern that allows us to deduce the orientation directly from the mapping. The few layers where the mapping is ambiguous (e.g. `line`) have an `orientation` setting that allows you to set the orientation explicitly.
Copy file name to clipboardExpand all lines: doc/syntax/layer/type/area.qmd
+17-3Lines changed: 17 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -10,8 +10,8 @@ The area layer is used to display absolute amounts over a sorted x-axis. It can
10
10
The following aesthetics are recognised by the area layer.
11
11
12
12
### Required
13
-
*`x`: Position along the x-axis.
14
-
*`y`: Position along the y-axis.
13
+
*Primary axis (e.g. `x`): The value of the independent variable.
14
+
*Secondary axis (e.g. `y`): The value of the dependent variable.
15
15
16
16
### Optional
17
17
*`stroke`: The colour of the contour lines.
@@ -22,9 +22,15 @@ The following aesthetics are recognised by the area layer.
22
22
23
23
## Settings
24
24
*`position`: Determines the position adjustment to use for the layer (default is `'stack'`)
25
+
*`orientation`: The orientation of the layer, see the [Orientation section](#orientation). One of the following:
26
+
*`'aligned'` to align the layer's primary axis with the coordinate system's first axis.
27
+
*`'transposed'` to align the layer's primary axis with the coordinate system's second axis.
25
28
26
29
## Data transformation
27
-
The area layer does not transform its data but passes it through unchanged.
30
+
The area layer sorts the data along its primary axis
31
+
32
+
## Orientation
33
+
Area plots are sorted and connected along their primary axis. Since the primary axis cannot be deduced from the mapping it must be specified using the `orientation` setting. E.g. if you wish to create a vertical area plot you need to set `orientation => 'transposed'` to indicate that the primary layer axis follows the second axis of the coordinate system.
28
34
29
35
## Examples
30
36
@@ -73,3 +79,11 @@ An alternative is to center the stacks to create a steamgraph
73
79
VISUALISE Date AS x, Value AS y, Series AS colour FROM long_airquality
74
80
DRAW area SETTING position => 'stack', center => true
75
81
```
82
+
83
+
You can combine this with the `orientation` setting to make a vertical steamgraph
84
+
85
+
```{ggsql}
86
+
VISUALISE Date AS y, Value AS x, Series AS colour FROM long_airquality
87
+
DRAW area
88
+
SETTING position => 'stack', center => true, orientation => 'transposed'
Copy file name to clipboardExpand all lines: doc/syntax/layer/type/bar.qmd
+21-5Lines changed: 21 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -13,8 +13,8 @@ The following aesthetics are recognised by the bar layer.
13
13
The bar layer has no required aesthetics
14
14
15
15
### Optional
16
-
*`x`: Position on the x-axis. If missing all records will be shown in the same bar
17
-
*`y`: The height of the plot. If missing, it will be calculated by the layer
16
+
*Primary axis (e.g. `x`): The categories to create bars for. If missing all records will be shown in the same bar
17
+
*Secondary axis (e.g. `y`): The height of the bars. If missing, it will be calculated by the layer
18
18
*`colour`: The default colour of each bar
19
19
*`stroke`: The colour of the stroke around each bar. Overrides `colour`
20
20
*`fill`: The fill colour of each bar. Overrides `colour`
@@ -27,7 +27,7 @@ The bar layer has no required aesthetics
27
27
*`width`: The width of the bars as a proportion of the available width
28
28
29
29
## Data transformation
30
-
If `y`has not been mapped the layer will calculate it for you.
30
+
If the secondary axis has not been mapped the layer will calculate counts for you and display these as the secondary axis.
31
31
32
32
### Properties
33
33
@@ -40,7 +40,10 @@ If `y` has not been mapped the layer will calculate it for you.
40
40
41
41
### Default remappings
42
42
43
-
*`count AS y`: By default the barplot will show count as the height of the bars
43
+
*`count AS <secondary axis>`: By default the barplot will show count as the height of the bars
44
+
45
+
## Orientation
46
+
Bar plots have categories along their primary axis. The orientation is deduced directly from the mapping. To create a horizontal bar plot you map the categories to `y` instead of `x` (assuming a default Cartesian coordinate system).
44
47
45
48
## Examples
46
49
@@ -97,6 +100,19 @@ SCALE BINNED x
97
100
SETTING breaks => 10
98
101
```
99
102
103
+
Create a horizontal bar plot by changing the mapping
104
+
105
+
```{ggsql}
106
+
VISUALISE FROM ggsql:penguins
107
+
DRAW bar
108
+
MAPPING species AS y
109
+
```
110
+
100
111
And use with a polar coordinate system to create a pie chart
Copy file name to clipboardExpand all lines: doc/syntax/layer/type/boxplot.qmd
+19-8Lines changed: 19 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -9,8 +9,8 @@ Boxplots display a summary of a continuous distribution. In the style of Tukey,
9
9
The following aesthetics are recognised by the boxplot layer.
10
10
11
11
### Required
12
-
*`x`: Position on the x-axis
13
-
*`y`: Position on the y-axis
12
+
*Primary axis (e.g. `x`): The categorical variable to group by
13
+
*Secondary axis (e.g. `y`): The continuous variable to summarize
14
14
15
15
### Optional
16
16
*`stroke`: The colour of the box contours, whiskers, median line and outliers.
@@ -29,11 +29,11 @@ The following aesthetics are recognised by the boxplot layer.
29
29
*`width`: Relative width of the boxes. Defaults to `0.9`.
30
30
31
31
## Data transformation
32
-
Per group, data will be divided into 4 quartiles and summary statistics will be derived from their extremes.
33
-
Because number of observations per quartile may differ by one, the result of this approach may slightly differ from a pure quantile-based approach.
34
-
The central line represents the median.
35
-
The boxes are displayed from the 25th up to the 75th percentiles.
36
-
The whiskers are calculated from the 25th/75th percentiles +/- the IQR times `coef`, but no more extreme than the data extrema.
32
+
Per group, data will be divided into 4 quartiles and summary statistics will be derived from their extremes.
33
+
Because number of observations per quartile may differ by one, the result of this approach may slightly differ from a pure quantile-based approach.
34
+
The central line represents the median.
35
+
The boxes are displayed from the 25th up to the 75th percentiles.
36
+
The whiskers are calculated from the 25th/75th percentiles +/- the IQR times `coef`, but no more extreme than the data extrema.
37
37
Observations are considered outliers when they are more extreme than the whiskers.
38
38
39
39
### Calculated statistics
@@ -43,7 +43,10 @@ Observations are considered outliers when they are more extreme than the whisker
43
43
44
44
### Default remapping
45
45
46
-
*`value AS y`: By default the values are displayed along the y-axis.
46
+
*`value AS <secondary axis>`: By default the values are displayed along the secondary axis.
47
+
48
+
## Orientation
49
+
The boxplot has its categorical groups along the primary axis and the continuous values along the secondary axis. The orientation can be deduced from the scale types or from the mapping. To create a horizontal boxplot, map the categorical variable to `y` and the continuous variable to `x` (assuming a default Cartesian coordinate system).
47
50
48
51
### Examples
49
52
@@ -83,3 +86,11 @@ DRAW boxplot
83
86
MAPPING species AS x, bill_len AS y
84
87
SETTING coef => 0.1
85
88
```
89
+
90
+
Create a horizontal boxplot by swapping `x` and `y`:
Copy file name to clipboardExpand all lines: doc/syntax/layer/type/density.qmd
+5-2Lines changed: 5 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ Visualise the distribution of a single continuous variable by computing a kernel
10
10
The following aesthetics are recognised by the density layer.
11
11
12
12
### Required
13
-
*`x`: Position on the x-axis.
13
+
*Primary axis (e.g. `x`): The continuous variable for which to estimate density.
14
14
15
15
### Optional
16
16
*`stroke`: The colour of the contour lines.
@@ -62,7 +62,10 @@ $$
62
62
63
63
### Default remappings
64
64
65
-
*`density AS y`: By default the density layer will display the computed density along the y-axis.
65
+
*`density AS <secondary axis>`: By default the density layer will display the computed density along the secondary axis.
66
+
67
+
## Orientation
68
+
The density has its primary axis along the variable for which density is computed. The orientation can be deduced from the mapping. To create a horizontal density plot, map the variable to `y` instead of `x` (assuming a default Cartesian coordinate system).
Copy file name to clipboardExpand all lines: doc/syntax/layer/type/errorbar.qmd
+6-5Lines changed: 6 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -10,11 +10,9 @@ Errorbars are used to display paired metrics, typically some interval, for a var
10
10
The following aesthetics are recognised by the errorbar layer.
11
11
12
12
### Required
13
-
*`x` or `y`: Position on the x- or y-axis. These are mutually exclusive.
14
-
*`xmin` or `ymin`: Position of one of the interval ends orthogonal to the main position. These are also mutually exclusive.
15
-
*`xmax` or `ymax`: Position of the other interval end orthogonal to the main position. These are also mutually exclusive.
16
-
17
-
Note that the required aesthetics is either a set of {`x`, `ymin`, `ymax`} or {`y`, `xmin`, `xmax`} and *not* a combination of the two.
13
+
* Primary axis (e.g. `x`): Position along the primary axis
14
+
* Secondary axis minimum (e.g. `ymin`): Lower position along the secondary axis.
15
+
* Secondary axis maximum (e.g. `ymax`): Upper position along the secondary axis.
18
16
19
17
### Optional
20
18
*`stroke`/`colour`: The colour of the lines in the errorbar.
@@ -28,6 +26,9 @@ Note that the required aesthetics is either a set of {`x`, `ymin`, `ymax`} or {`
28
26
## Data transformation
29
27
The errorbar layer does not transform its data but passes it through unchanged.
30
28
29
+
## Orientation
30
+
The orientation of errorbar layers is deduced directly from the mapping, because the interval is mapped to the secondary axis. To create a horizontal errorbar layer, you map the independent variable to `y` instead of `x` and the interval to `xmin` and `xmax` (assuming a default Cartesian coordinate system).
Copy file name to clipboardExpand all lines: doc/syntax/layer/type/histogram.qmd
+15-4Lines changed: 15 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,13 @@ title: "Histogram"
4
4
5
5
> Layers are declared with the [`DRAW` clause](../../clause/draw.qmd). Read the documentation for this clause for a thorough description of how to use it.
6
6
7
-
Visualise the distribution of a single continuous variable by dividing the x axis into bins and counting the number of observations in each bin. If providing a weight then a weighted histogram is calculated instead.
7
+
Visualise the distribution of a single continuous variable by dividing the primary axis into bins and counting the number of observations in each bin. If providing a weight then a weighted histogram is calculated instead.
8
8
9
9
## Aesthetics
10
10
The following aesthetics are recognised by the bar layer.
11
11
12
12
### Required
13
-
*`x`: Position on the x-axis
13
+
*Primary axis (e.g. `x`): The continuous variable to bin
14
14
15
15
### Optional
16
16
*`colour`: The default colour of each bar
@@ -27,7 +27,7 @@ The following aesthetics are recognised by the bar layer.
27
27
*`closed`: Either `'left'` or `'right'` (default). Determines whether the bin intervals are closed to the left or right side
28
28
29
29
## Data transformation
30
-
The histogram layer will bin the records in each group and count them. By default it will map the count to `y`.
30
+
The histogram layer will bin the records in each group and count them. By default it will map the count to the secondary axis.
31
31
32
32
### Properties
33
33
@@ -40,7 +40,10 @@ The histogram layer will bin the records in each group and count them. By defaul
40
40
41
41
### Default remappings
42
42
43
-
*`count AS y`: By default the histogram will show count as the height of the bars
43
+
*`count AS <secondary axis>`: By default the histogram will show count as the height of the bars
44
+
45
+
## Orientation
46
+
The histogram has its primary axis along the binned variable. The orientation is deduced directly from the mapping. To create a horizontal histogram, you map the variable to `y` instead of `x` (assuming a default Cartesian coordinate system).
44
47
45
48
## Examples
46
49
@@ -86,3 +89,11 @@ DRAW histogram
86
89
MAPPING body_mass AS x
87
90
SETTING binwidth => 100
88
91
```
92
+
93
+
Create a histogram along the y axis by changing the mapping
Copy file name to clipboardExpand all lines: doc/syntax/layer/type/line.qmd
+9-3Lines changed: 9 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -10,8 +10,8 @@ The line layer is used to create lineplots. Lineplots always connects records al
10
10
The following aesthetics are recognised by the line layer.
11
11
12
12
### Required
13
-
*`x`: Position along the x-axis
14
-
*`y`: Position along the y-axis
13
+
*Primary axis (e.g. `x`): The value of the independent variable.
14
+
*Secondary axis (e.g. `y`): The value of the dependent variable.
15
15
16
16
### Optional
17
17
*`colour`/`stroke`: The colour of the line
@@ -21,9 +21,15 @@ The following aesthetics are recognised by the line layer.
21
21
22
22
## Settings
23
23
*`position`: Determines the position adjustment to use for the layer (default is `'identity'`)
24
+
*`orientation`: The orientation of the layer, see the [Orientation section](#orientation). One of the following:
25
+
*`'aligned'` to align the layer's primary axis with the coordinate system's first axis.
26
+
*`'transposed'` to align the layer's primary axis with the coordinate system's second axis.
24
27
25
28
## Data transformation
26
-
The line layer does not transform its data but passes it through unchanged
29
+
The line layer sorts the data along its primary axis.
30
+
31
+
## Orientation
32
+
Line plots are sorted and connected along their primary axis. Since the primary axis cannot be deduced from the mapping it must be specified using the `orientation` setting. If you wish to create a vertical line plot, you need to set `orientation => 'transposed'` to indicate that the primary layer axis follows the second axis of the coordinate system.
Copy file name to clipboardExpand all lines: doc/syntax/layer/type/linear.qmd
+8-1Lines changed: 8 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,8 @@ $$
13
13
14
14
Where $a$ is the `intercept` and $\beta$ is the `coef`.
15
15
16
+
> The linear layer doesn't have a natural extend along either axes and the scale ranges can thus not be deduced from it. If the linear layer is the only layer in the visualisation you must specify the position scale ranges manually.
17
+
16
18
## Aesthetics
17
19
The following aesthetics are recognised by the abline layer.
18
20
@@ -27,11 +29,16 @@ The following aesthetics are recognised by the abline layer.
27
29
*`linetype`: The type of the line, i.e. the dashing pattern
28
30
29
31
## Settings
30
-
The linear layer has no additional settings.
32
+
*`orientation`: The orientation of the layer, see the [Orientation section](#orientation). One of the following:
33
+
*`'aligned'` to align the layer's primary axis with the coordinate system's first axis.
34
+
*`'transposed'` to align the layer's primary axis with the coordinate system's second axis.
31
35
32
36
## Data transformation
33
37
The linear layer does not transform its data but passes it through unchanged.
34
38
39
+
## Orientation
40
+
Linear layers use the predictor ($x$) for their primary axis and the response $y$ for its secondary axis. Since the primary axis cannot be deduced from the mapping it must be specified using the `orientation` setting. E.g. to create a vertical linear plot, you need to set `orientation => 'transposed'` to indicate that the primary layer axis follows the second axis of the coordinate system.
0 commit comments