Skip to content

Commit a28ccd0

Browse files
Fix typos (#380)
1 parent a965a9d commit a28ccd0

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

doc/syntax/clause/scale.qmd

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22
title: "Specify aesthetic scaling with `SCALE`"
33
---
44

5-
Scales are an important concept in ggsql. While DRAW clauses define what to draw and what data to base the drawing on, scales control *how* that data is interpreted, understood, and translated. Because of this a proper understanding of the `SCALE` clause is integral to releasing all the power of ggsql. Still, scales always comes with sensible defaults so unlike `DRAW` clauses you may not need them for all your visualisations.
5+
Scales are an important concept in ggsql. While DRAW clauses define what to draw and what data to base the drawing on, scales control *how* that data is interpreted, understood, and translated. Because of this a proper understanding of the `SCALE` clause is integral to releasing all the power of ggsql. Still, scales always come with sensible defaults so unlike `DRAW` clauses you may not need them for all your visualisations.
66

77
## Clause syntax
88
The `SCALE` clause takes a number of subclauses, all of them optional:
99

10-
```ggsql
11-
SCALE <type> <aesthetic> FROM <input-range> TO <output-range> VIA <transform>
12-
SETTING <parameter> => <value>, ...
13-
RENAMING <break-value> => <string>, ...
14-
```
10+
```ggsql SCALE <type> <aesthetic> FROM <input-range> TO <output-range> VIA
11+
<transform> SETTING <parameter> => <value>, ... RENAMING <break-value> =>
12+
<string>, ... ```
1513
16-
The `type` defines the class of scale to use. It can be one of four different types:
14+
The `type` defines the class of scale to use. It can be one of five different types:
1715
1816
* `CONTINUOUS` to interpret and treat data as continuous
1917
* `DISCRETE` to interpret and treat data as discrete or categorical
@@ -23,9 +21,9 @@ The `type` defines the class of scale to use. It can be one of four different ty
2321
2422
Read more about each type at their dedicated documentation. You do not have to specify the type as it is deduced from the transform, input range, or data if left blank.
2523
26-
You *must* specify an aesthetic so that the scale knows which mapping it belongs to.
27-
For position aesthetics you will provide the base name (`x` or `y`) even though you are mapping to e.g. `xmin`.
28-
Creating a scale for `colour` (or `color`) will create a scale for both fill and stroke colour based on the settings.
24+
You *must* specify an aesthetic so that the scale knows which mapping it belongs to.
25+
For position aesthetics you will provide the base name (`x` or `y`) even though you are mapping to e.g. `xmin`.
26+
Creating a scale for `colour` (or `color`) will create a scale for both fill and stroke colour based on the settings.
2927
3028
### `FROM`
3129
```ggsql
@@ -45,7 +43,7 @@ The `TO` clause defines the output range of the scale, i.e. what the data is tra
4543
VIA <transform>
4644
```
4745

48-
The `VIA` clause defines a transform which is applied to the data before mapping it to the output range. While transforms are often understood as mathematical transforms, in ggsql it also defines casting of input data. E.g. the `integer` transform cast all input to integer before mapping. Transforms also takes care of creating breaks that are meaningful for the specific transform, e.g. in the case of the log10 transform where breaks are created to fit the power of 10. Different transforms are available to different scale types.
46+
The `VIA` clause defines a transform which is applied to the data before mapping it to the output range. While transforms are often understood as mathematical transforms, in ggsql it also defines casting of input data. E.g. the `integer` transform cast all input to integer before mapping. Transforms also take care of creating breaks that are meaningful for the specific transform, e.g. in the case of the log10 transform where breaks are created to fit the power of 10. Different transforms are available to different scale types.
4947

5048
### `SETTING`
5149
```ggsql
@@ -59,7 +57,7 @@ This clause behaves much like the `SETTINGS` clause in `DRAW`, in that it allows
5957
RENAMING <break-value> => <string>, ...
6058
```
6159

62-
This clause works much like the `LABEL` clause but works on the break names of the scale. The general syntax is that you provide the name of the break on the left and what it should appear as on the right, e.g `'adelie' => 'Pygoscelis adeliae'`. The clause is understood as a look-up table in the sense that if you provide a renaming for a break that doesn't appear in the scale then nothing will happen and if a break exist but doesn't have a renaming defined it will go through unaltered. To suppress the label of a specific break you can rename it to `null`, e.g. `'adelie' => null`. This will not remove the break, only the label.
60+
This clause works much like the `LABEL` clause but works on the break names of the scale. The general syntax is that you provide the name of the break on the left and what it should appear as on the right, e.g `'adelie' => 'Pygoscelis adeliae'`. The clause is understood as a look-up table in the sense that if you provide a renaming for a break that doesn't appear in the scale then nothing will happen and if a break exists but doesn't have a renaming defined it will go through unaltered. To suppress the label of a specific break you can rename it to `null`, e.g. `'adelie' => null`. This will not remove the break, only the label.
6361

6462
#### Break formatting
6563
Apart from the direct renaming described above it is also possible to provide a formatting function to be applied to all breaks. The syntax for this is `* => '...'` with the content of the string on the right being a string interpolation format. The basic syntax for this is that the break value will be inserted into any place where `{}` appears. This means that e.g. `* => '{} species'` will result in the label "adelie species" for the break "adelie". Besides simply inserting the value as-is, it is also possible to apply a formatter to the label before insertion by naming a formatter inside the curly braces prefixed with `:`. Known formatters are:

0 commit comments

Comments
 (0)