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
### Sunburst of a rectangular DataFrame with discrete color argument in px.sunburst
92
+
93
+
When the argument of `color` corresponds to non-numerical data, discrete colors are used. If a sector has the same value of the `color` column for all its children, then the corresponding color is used, otherwise the first color of the discrete color sequence is used.
In the example below the color of `Saturday` and `Sunday` sectors is the same as `Dinner` because there are only Dinner entries for Saturday and Sunday. However, for Female -> Friday there are both lunches and dinners, hence the "mixed" color (blue here) is used.
If the dataset is not fully rectangular, missing values should be supplied as `None`. Note that the parents of `None` entries must be a leaf, i.e. it cannot have other children than `None` (otherwise a `ValueError` is raised).
Copy file name to clipboardExpand all lines: doc/python/treemaps.md
+30-4
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ jupyter:
6
6
extension: .md
7
7
format_name: markdown
8
8
format_version: '1.2'
9
-
jupytext_version: 1.3.0
9
+
jupytext_version: 1.3.1
10
10
kernelspec:
11
11
display_name: Python 3
12
12
language: python
@@ -20,7 +20,7 @@ jupyter:
20
20
name: python
21
21
nbconvert_exporter: python
22
22
pygments_lexer: ipython3
23
-
version: 3.7.3
23
+
version: 3.6.8
24
24
plotly:
25
25
description: How to make Treemap Charts with Plotly
26
26
display_as: basic
@@ -66,17 +66,42 @@ fig.show()
66
66
67
67
If a `color` argument is passed, the color of a node is computed as the average of the color values of its children, weighted by their values.
68
68
69
+
**Note**: for best results, ensure that the first `path` element is a single root node. In the examples below we are creating a dummy column containing identical values for each row to achieve this.
### Treemap of a rectangular DataFrame with discrete color argument in px.treemap
84
+
85
+
When the argument of `color` corresponds to non-numerical data, discrete colors are used. If a sector has the same value of the `color` column for all its children, then the corresponding color is used, otherwise the first color of the discrete color sequence is used.
86
+
87
+
```python
88
+
import plotly.express as px
89
+
df = px.data.tips()
90
+
df["all"] ="all"# in order to have a single root node
In the example below the color of Saturday and Sunday sectors is the same as Dinner because there are only Dinner entries for Saturday and Sunday. However, for Female -> Friday there are both lunches and dinners, hence the "mixed" color (blue here) is used.
96
+
97
+
```python
98
+
import plotly.express as px
99
+
df = px.data.tips()
100
+
df["all"] ="all"# in order to have a single root node
0 commit comments