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
* implement polygon
* path writing logic as function
* simplify path rendering
* add docs
* for consistency, also put bar logic in function
* fix lazily copied sentences
* clarify comment
* include polygon as link
* remove outdated tests
* add linetype aesthetic
* Also include linetype in docs
Copy file name to clipboardExpand all lines: doc/syntax/layer/path.qmd
+51-2Lines changed: 51 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ title: "Path"
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
-
The path layer is used to create lineplots, but contrary to the [line layer](line.qmd) the data will not be connected along the x-axis. Instead records are connected in the order they appear in the data. Because of this the ordering is quite important and you may want to use the [`ORDER BY`](../clause/draw.qmd#order-by) clause to ensure data comes out of the back-end in the desired order. Lines are divided due to their grouping, which is the combination of the discrete mapped aesthetics and the columns specified in the layers [`PARTITION BY`](../clause/draw.qmd#partition-by).
7
+
The path layer is used to create lineplots, but contrary to the [line layer](line.qmd) the data will not be connected along the x-axis. Instead records are connected in the order they appear in the data. Lines are divided due to their grouping, which is the combination of the discrete mapped aesthetics and the columns specified in the layers [`PARTITION BY`](../clause/draw.qmd#partition-by).
8
8
9
9
## Aesthetics
10
10
The following aesthetics are recognised by the path layer.
@@ -27,4 +27,53 @@ The line layer does not transform its data but passes it through unchanged
27
27
28
28
## Examples
29
29
30
-
TBD
30
+
```{ggsql}
31
+
#| code-fold: true
32
+
#| code-summary: "Create example data"
33
+
CREATE TABLE df AS
34
+
SELECT * FROM (VALUES
35
+
(1.0, 1.0, 'A'),
36
+
(2.0, 1.0, 'A'),
37
+
(1.0, 3.0, 'A'),
38
+
(3.0, 1.0, 'B'),
39
+
(2.0, 3.0, 'B'),
40
+
(3.0, 3.0, 'B'),
41
+
) AS t(x, y, id)
42
+
```
43
+
44
+
Simple example path.
45
+
46
+
```{ggsql}
47
+
VISUALISE x, y FROM df
48
+
DRAW path
49
+
```
50
+
51
+
Contrary to `line` drawings, `path` is not forced to follow the order along the axis.
52
+
53
+
```{ggsql}
54
+
VISUALISE x, y FROM df
55
+
DRAW path MAPPING 'Path' AS colour
56
+
DRAW line MAPPING 'Line' AS colour
57
+
```
58
+
59
+
Groups of individual paths can be declared via `PARTITION BY`.
60
+
61
+
```{ggsql}
62
+
VISUALISE x, y FROM df
63
+
DRAW path PARTITION BY id
64
+
```
65
+
66
+
Invoking a group through discrete aesthetics works as well.
67
+
68
+
```{ggsql}
69
+
VISUALISE x, y FROM df
70
+
DRAW path MAPPING id AS colour
71
+
```
72
+
73
+
Compared to polygons, paths don't close their shapes and fill their interiors.
> 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
+
7
+
Polygons can be used to draw arbitrary closed shapes based on an ordered sequence of x,y-coordinates. They are similar to [paths](path.qmd), but close the shapes and fill the interior.
8
+
9
+
## Aesthetics
10
+
The following aesthetics are recognised by the polygon layer.
11
+
12
+
### Required
13
+
*`x` Position along the x-axis.
14
+
*`y` Position along the y-axis.
15
+
16
+
### Optional
17
+
*`stroke` The colour of the contour lines.
18
+
*`fill` The colour of the inner area.
19
+
*`colour` Shorthand for setting `stroke` and `fill` simultaneously.
20
+
*`opacity` The opacity of colours.
21
+
*`linewidth` The width of the contour lines.
22
+
*`linetype` The dash pattern of the contour line.
23
+
24
+
## Settings
25
+
The polygon layer has no additional settings
26
+
27
+
## Data transformation
28
+
The polygon layer does not transform its data but passes it through unchanged
29
+
30
+
## Examples
31
+
32
+
```{ggsql}
33
+
#| code-fold: true
34
+
#| code-summary: "Create example data"
35
+
CREATE TABLE df AS
36
+
SELECT * FROM (VALUES
37
+
(1.0, 1.0, 'A'),
38
+
(1.0, 3.0, 'A'),
39
+
(2.0, 1.0, 'A'),
40
+
(2.0, 3.0, 'B'),
41
+
(3.0, 1.0, 'B'),
42
+
(3.0, 3.0, 'B'),
43
+
) AS t(x, y, id)
44
+
```
45
+
46
+
Simple example polygon.
47
+
48
+
```{ggsql}
49
+
VISUALISE x, y FROM df
50
+
DRAW polygon
51
+
```
52
+
53
+
Groups of individual polygons can be declared via `PARTITION BY`.
54
+
55
+
```{ggsql}
56
+
VISUALISE x, y FROM df
57
+
DRAW polygon PARTITION BY id
58
+
```
59
+
60
+
Invoking a group through discrete aesthetics works as well.
0 commit comments