Skip to content

Commit cff538b

Browse files
committed
Added docs for facets/pivot for the plotly docs
1 parent b003d07 commit cff538b

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

docs/assets/plotly_facet.png

62.2 KB
Loading

docs/ref-plotly.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,64 @@ layout:
105105
| educ_higher | 7 | 2.587991718426501E-4 | 5.175983436853002E-4 |
106106
| ... | ... | ... | ... |
107107
108+
### Pivot
109+
110+
With the pivot attribute, you can modify the dataset by converting it from wide to long format.
111+
112+
|**Field**|**Description**|
113+
|---------|---------------|
114+
|exclude|Array of column names which should be ignored by the converting|
115+
|namesTo|name of the new column that contains the attributes|
116+
|valuesTo|name of the new column that contains the values|
117+
118+
Besides converting, it is also possible to rename columns and normalize values. These two options can also be configured in the pivot attribute.
119+
120+
|**Field**|**Description**|
121+
|---------|---------------|
122+
|rename|The rename Object contains a map where the keys specify the old column name and the values specify the new column name|
123+
|normalize|The normalize Object contains two entries. The `target` entry accepts a column name as a `String` for the columns that should be normalized, while the `groupBy` attribute takes an array of column names as `Strings`. The values will be normalized for the rows where the values from the `groupBy` attribute are identical.|
124+
125+
#### Example pivot data snippet
126+
127+
```yaml
128+
pivot:
129+
exclude:
130+
- age
131+
- dist_group
132+
- main_mode
133+
namesTo: names
134+
valuesTo: values
135+
rename:
136+
ref_share: Ref.
137+
sim_share: Sim.
138+
normalize:
139+
target: values
140+
groupBy:
141+
- names
142+
- dist_group
143+
- age
144+
```
145+
146+
### Facets
147+
148+
![plotly example](assets/plotly_facet.png)
149+
150+
To create facets you have to specify the facet_col/facet_row attribute inside the traces array
151+
152+
|**Field**|**Description**|**Example**|
153+
|---------|---------------|-----------|
154+
|facet_col|Defines which values in wich row in the dataset should be seperated into facet columns|`$dataset.age`|
155+
|facet_row|Defines which values in wich row in the dataset should be seperated into facet rows|`$dataset.mode`|
156+
157+
#### Example facets data snippet
158+
159+
```yaml
160+
traces:
161+
- x: $dataset.distance_group
162+
y: $dataset.share
163+
orientation: v
164+
type: bar
165+
name: $dataset.vehicle
166+
facet_col: $dataset.sex
167+
facet_row: $dataset.monthly_pass
168+
```

0 commit comments

Comments
 (0)