Open
Conversation
georgestagg
approved these changes
Mar 30, 2026
Collaborator
georgestagg
left a comment
There was a problem hiding this comment.
This looks like a great introduction, thanks!
| @@ -0,0 +1,101 @@ | |||
| --- | |||
Collaborator
| SETTING stroke => null, bins => 20 | ||
| ``` | ||
|
|
||
| but, if mappings and data source have already been taken care off, it can be as simple as |
Collaborator
There was a problem hiding this comment.
Suggested change
| but, if mappings and data source have already been taken care off, it can be as simple as | |
| but, if mappings and data source have already been taken care of, it can be as simple as |
| ``` | ||
|
|
||
| ### `SCALE` | ||
| As [described above](#scales) ggsql automatically creates a default for mapped aesthetics and if those suit your need there is no reason to modify them. However, if change is needed you do it with the [`SCALE`](../syntax/clause/scale.qmd) clause. |
Collaborator
There was a problem hiding this comment.
Suggested change
| As [described above](#scales) ggsql automatically creates a default for mapped aesthetics and if those suit your need there is no reason to modify them. However, if change is needed you do it with the [`SCALE`](../syntax/clause/scale.qmd) clause. | |
| As [described above](#scales), ggsql automatically creates a default for mapped aesthetics and if those suit your needs there is no reason to modify them. However, if change is needed you do it with the [`SCALE`](../syntax/clause/scale.qmd) clause. |
| ### `SCALE` | ||
| As [described above](#scales) ggsql automatically creates a default for mapped aesthetics and if those suit your need there is no reason to modify them. However, if change is needed you do it with the [`SCALE`](../syntax/clause/scale.qmd) clause. | ||
|
|
||
| The clause both allows you to set the type of scale, the input range, the output range, and transform, and let you control breaks and label formatting. So, the clause can end up with a lot of information but the syntax has been designed so it reads very natural. Further, every part is optional and can be left out if the default fits. An example of a rather complex `SCALE` clause could be: |
Collaborator
There was a problem hiding this comment.
Suggested change
| The clause both allows you to set the type of scale, the input range, the output range, and transform, and let you control breaks and label formatting. So, the clause can end up with a lot of information but the syntax has been designed so it reads very natural. Further, every part is optional and can be left out if the default fits. An example of a rather complex `SCALE` clause could be: | |
| The clause allows you to set the type of scale, the input range, the output range, the transformation, and lets you control breaks and label formatting. So, the clause can end up with a lot of information but the syntax has been designed so it reads very natural. Further, every part is optional and can be left out if the default fits. An example of a rather complex `SCALE` clause could be: |
| SETTING breaks => 4 | ||
| ``` | ||
|
|
||
| In the above we create a global mapping of bill_len to the `x` aesthetic and bill_dep to the `y` aesthetic using the built-in penguins dataset. We use `DRAW` to create two layers: A point layer for a scatter plot and a smooth layer for regression lines. For the point layer we _map_ the body_mass to size to create a bubble chart and _set_ the fill aesthetic to be empty (`null`) so only the outline is shown. For the smooth layer we set the layer parameter `method` to `'ols'` to estimate a straight regression line. Lastly, we modify the stroke scale to use the dark2 palette from the ColorBrewer project and apply a binned scale to size that goes from 4pt to 15pt with 4 breaks (resulting in 3 bins). |
Collaborator
There was a problem hiding this comment.
Suggested change
| In the above we create a global mapping of bill_len to the `x` aesthetic and bill_dep to the `y` aesthetic using the built-in penguins dataset. We use `DRAW` to create two layers: A point layer for a scatter plot and a smooth layer for regression lines. For the point layer we _map_ the body_mass to size to create a bubble chart and _set_ the fill aesthetic to be empty (`null`) so only the outline is shown. For the smooth layer we set the layer parameter `method` to `'ols'` to estimate a straight regression line. Lastly, we modify the stroke scale to use the dark2 palette from the ColorBrewer project and apply a binned scale to size that goes from 4pt to 15pt with 4 breaks (resulting in 3 bins). | |
| In the above we create a global mapping of bill_len to the `x` aesthetic and bill_dep to the `y` aesthetic using the built-in penguins dataset. We use `DRAW` to create two layers: A point layer for a scatter plot and a smooth layer for regression lines. For the point layer we _map_ the body_mass to size to create a bubble chart and _set_ the fill aesthetic to be empty (`null`) so only the outline is shown. For the smooth layer we set the layer parameter `method` to `'ols'` to estimate a straight regression line. Lastly, we modify the stroke scale to use the dark2 palette from the ColorBrewer project and apply a binned scale to `size` that goes from 4pt to 15pt with 4 breaks (resulting in 3 bins). |
| VISUALISE ... | ||
| ``` | ||
|
|
||
| Each block in the document are using the same session, so tables created in one block will be available in subsequent blocks. |
Collaborator
There was a problem hiding this comment.
Suggested change
| Each block in the document are using the same session, so tables created in one block will be available in subsequent blocks. | |
| Each block in the document uses the same session, so tables created in one block will be available in subsequent blocks. |
|
|
||
| The above alludes to the fact that coordinate systems have different position aesthetics. Often you expect `x` and `y` as position aesthetics and while these are indeed the default name for the [`cartesian`](../syntax/coord/cartesian.qmd) coordinate system they would be nonsensical for a [`polar`](../syntax/coord/polar.qmd) system which uses `radius` and `angle` as defaults. You can, however, freely define your own names, e.g. `r` and `a` for a polar system if you value brevity over comprehension. | ||
|
|
||
| `PROJECT` also takes a `SETTING` clause which works much like the `SETTING` clause in `DRAW` and `SCALE`, allowing you to modify the behavior of the coordinate system. An example of a full `PROJECT` query could be: |
Collaborator
There was a problem hiding this comment.
An example of a full
PROJECTquery could be
Should we call this a "query", since it's only partially complete? Maybe "statement", "snippet", "clause" or something else?
| ### `FACET` | ||
| Faceting is applied with the [`FACET`](../syntax/clause/facet.qmd) clause. It allows you to either facet by a single variable (`FACET var`) or by a combination of two variables `FACET var1 BY var2`. In the former case the small multiples are laid out in a row-wise manner, wrapping to the next row if there are more multiples than the number of column. In the latter case the first variable is related to the rows and the second is related to the columns. | ||
|
|
||
| There is an alternative to using the `FACET` variable, which is to map the variables directly to the facet aesthetics. There are three of these: `panel` is used when faceting by a single variable and `row` and `column` is used when faceting by two variables. `FACET var` is thus equivalent to `VISUALISE var AS panel`. Whichever you choose to use is thus a matter of personal preference as well as whether you also need to modify faceting behavior (in which case ) |
Collaborator
There was a problem hiding this comment.
whether you also need to modify faceting behavior (in which case )
I think the end of this went missing?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This PR builds upon the current Get started section and adds three additional pages for users to familarise themselves with. In addition it contains a range of fixes to bugs I uncovered as I developed the examples (all issues are unsurprisingly confined to the vegalite writer). The issues fixed are: