Skip to content

Commit e860847

Browse files
committed
added doc examples
1 parent 7ad9b69 commit e860847

File tree

3 files changed

+44
-5
lines changed

3 files changed

+44
-5
lines changed

doc/python/pie-charts.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jupyter:
55
text_representation:
66
extension: .md
77
format_name: markdown
8-
format_version: "1.2"
8+
format_version: '1.2'
99
jupytext_version: 1.3.0
1010
kernelspec:
1111
display_name: Python 3
@@ -73,6 +73,21 @@ fig = px.pie(df, values='tip', names='day', color_discrete_sequence=px.colors.se
7373
fig.show()
7474
```
7575

76+
### Using an explicit mapping for discrete colors
77+
78+
For more information about discrete colors, see the [dedicated page](/python/discrete-color).
79+
80+
```python
81+
import plotly.express as px
82+
df = px.data.tips()
83+
fig = px.pie(df, values='tip', names='day', color='day',
84+
color_discrete_map={'Thur':'lightcyan',
85+
'Fri':'cyan',
86+
'Sat':'royalblue',
87+
'Sun':'darkblue'})
88+
fig.show()
89+
```
90+
7691
### Customizing a pie chart created with px.pie
7792

7893
In the example below, we first create a pie chart with `px,pie`, using some of its options such as `hover_data` (which columns should appear in the hover) or `labels` (renaming column names). For further tuning, we call `fig.update_traces` to set other parameters of the chart (you can also use `fig.update_layout` for changing the layout).

doc/python/sunburst-charts.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jupyter:
55
text_representation:
66
extension: .md
77
format_name: markdown
8-
format_version: "1.2"
8+
format_version: '1.2'
99
jupytext_version: 1.3.0
1010
kernelspec:
1111
display_name: Python 3
@@ -109,6 +109,18 @@ fig = px.sunburst(df, path=['sex', 'day', 'time'], values='total_bill', color='t
109109
fig.show()
110110
```
111111

112+
### Using an explicit mapping for discrete colors
113+
114+
For more information about discrete colors, see the [dedicated page](/python/discrete-color).
115+
116+
```python
117+
import plotly.express as px
118+
df = px.data.tips()
119+
fig = px.sunburst(df, path=['sex', 'day', 'time'], values='total_bill', color='time',
120+
color_discrete_map={'(?)':'black', 'Lunch':'gold', 'Dinner':'darkblue'})
121+
fig.show()
122+
```
123+
112124
### Rectangular data with missing values
113125

114126
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).

doc/python/treemaps.md

+15-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ jupyter:
55
text_representation:
66
extension: .md
77
format_name: markdown
8-
format_version: "1.2"
9-
jupytext_version: 1.3.1
8+
format_version: '1.2'
9+
jupytext_version: 1.3.0
1010
kernelspec:
1111
display_name: Python 3
1212
language: python
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.6.8
23+
version: 3.7.3
2424
plotly:
2525
description: How to make Treemap Charts with Plotly
2626
display_as: basic
@@ -101,6 +101,18 @@ fig = px.treemap(df, path=['all', 'sex', 'day', 'time'], values='total_bill', co
101101
fig.show()
102102
```
103103

104+
### Using an explicit mapping for discrete colors
105+
106+
For more information about discrete colors, see the [dedicated page](/python/discrete-color).
107+
108+
```python
109+
import plotly.express as px
110+
df = px.data.tips()
111+
fig = px.treemap(df, path=['sex', 'day', 'time'], values='total_bill', color='time',
112+
color_discrete_map={'(?)':'black', 'Lunch':'gold', 'Dinner':'darkblue'})
113+
fig.show()
114+
```
115+
104116
### Rectangular data with missing values
105117

106118
If the dataset is not fully rectangular, missing values should be supplied as `None`.

0 commit comments

Comments
 (0)