Skip to content

Commit ad8b403

Browse files
Merge pull request #2001 from plotly/doc-prod
Doc prod back merge
2 parents 5691295 + 55be0e2 commit ad8b403

12 files changed

+297
-45
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
3636
section [#1969](https://github.com/plotly/plotly.py/pull/1969).
3737
- All continuous colorscales now accept a `_r` suffix that reverses their direction [#1933](https://github.com/plotly/plotly.py/pull/1933)
3838
- Docstrings of plotly.py are now doctested [#1921](https://github.com/plotly/plotly.py/pull/1921).
39+
- Reversing a predefined colorscale by appending `_r` to its name [#1933](https://github.com/plotly/plotly.py/pull/1933)
3940

4041
## [4.3.0] - 2019-11-11
4142

Diff for: doc/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ $(HTML_DIR)/2019-07-03-%.html: $(IPYNB_DIR)/%.ipynb
3838
@echo "[nbconvert] $<"
3939
@jupyter nbconvert $< --to html --template nb.tpl \
4040
--output-dir $(HTML_DIR) --output 2019-07-03-$*.html \
41-
--execute
41+
--execute > $(FAIL_DIR)/$* 2>&1 && rm -f $(FAIL_DIR)/$*
4242

4343

4444
$(REDIR_DIR)/2019-07-03-redirect-next-%.html: $(IPYNB_DIR)/%.ipynb

Diff for: doc/apidoc/plotly.express.rst

+7
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,19 @@ plotly's high-level API for rapid figure generation. ::
3333
box
3434
strip
3535
histogram
36+
pie
37+
treemap
38+
sunburst
39+
funnel
40+
funnel_area
3641
scatter_matrix
3742
parallel_coordinates
3843
parallel_categories
3944
choropleth
45+
choropleth_mapbox
4046
density_contour
4147
density_heatmap
48+
density_mapbox
4249
imshow
4350

4451

Diff for: doc/python/box-plots.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jupyter:
3939
A [box plot](https://en.wikipedia.org/wiki/Box_plot) is a statistical representation of numerical data through their quartiles. The ends of the box represent the lower and upper quartiles, while the median (second quartile) is marked by a line inside the box. For other statistical representations of numerical data, see [other statistical charts](https://plot.ly/python/statistical-charts/).
4040

4141

42-
## Box Plot with Plotly Express
42+
## Box Plot with `plotly.express`
4343

4444
[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/).
4545

Diff for: doc/python/colorscales.md

+24-2
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.1'
9-
jupytext_version: 1.2.1
8+
format_version: '1.2'
9+
jupytext_version: 1.3.0
1010
kernelspec:
1111
display_name: Python 3
1212
language: python
@@ -62,6 +62,28 @@ fig = px.scatter(iris, x="sepal_width", y="sepal_length",
6262
fig.show()
6363
```
6464

65+
### Reversing a predefined colorscale
66+
67+
You can reverse a predefined colorscale by appending `_r` to its name, for colorscales given either as a string or a `plotly` object.
68+
69+
```python
70+
import plotly.express as px
71+
iris = px.data.iris()
72+
fig = px.scatter(iris, x="sepal_width", y="sepal_length",
73+
color="sepal_length", color_continuous_scale='Magma_r')
74+
75+
fig.show()
76+
```
77+
78+
```python
79+
import plotly.express as px
80+
data = [[1, .3, .5, .9],
81+
[.3, .1, .4, 1],
82+
[.2, .8, .9, .3]]
83+
fig = px.imshow(data, color_continuous_scale=px.colors.diverging.Tealrose_r)
84+
fig.show()
85+
```
86+
6587
### Custom Discretized Heatmap Colorscale
6688

6789
```python

Diff for: doc/python/funnel-charts.md

+59-11
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
---
22
jupyter:
33
jupytext:
4+
notebook_metadata_filter: plotly
45
text_representation:
56
extension: .md
67
format_name: markdown
7-
format_version: '1.1'
8-
jupytext_version: 1.1.1
8+
format_version: '1.2'
9+
jupytext_version: 1.3.0
910
kernelspec:
1011
display_name: Python 3
1112
language: python
1213
name: python3
1314
plotly:
14-
permalink: python/funnel-charts/
15-
redirect_from: python/funnel-chart/
1615
description: How to make funnel-chart plots in Python with Plotly.
17-
name: Funnel Chart
18-
thumbnail: thumbnail/funnel.jpg
19-
language: python
2016
display_as: financial
21-
order: 4
17+
language: python
2218
layout: base
19+
name: Funnel Chart
20+
order: 4
2321
page_type: example_index
22+
permalink: python/funnel-charts/
23+
redirect_from: python/funnel-chart/
24+
thumbnail: thumbnail/funnel.jpg
2425
---
2526

2627

@@ -29,7 +30,40 @@ jupyter:
2930
Funnel charts are often used to represent data in different stages of a business process. It’s an important mechanism in Business Intelligence to identify potential problem areas of a process. For example, it’s used to observe the revenue or loss in a sales process for each stage, and displays values that are decreasing progressively. Each stage is illustrated as a percentage of the total of all values.
3031

3132

32-
### Basic Funnel Plot
33+
### Basic Funnel Plot with plotly.express
34+
35+
[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/).
36+
37+
With `px.funnel`, each row of the DataFrame is represented as a stage of the funnel.
38+
39+
40+
```python
41+
import plotly.express as px
42+
data = dict(
43+
number=[39, 27.4, 20.6, 11, 2],
44+
stage=["Website visit", "Downloads", "Potential customers", "Requested price", "invoice sent"])
45+
fig = px.funnel(data, x='number', y='stage')
46+
fig.show()
47+
```
48+
49+
### Stacked Funnel Plot with plotly.express
50+
51+
```python
52+
import plotly.express as px
53+
import pandas as pd
54+
stages = ["Website visit", "Downloads", "Potential customers", "Requested price", "invoice sent"]
55+
df_mtl = pd.DataFrame(dict(number=[39, 27.4, 20.6, 11, 3], stage=stages))
56+
df_mtl['office'] = 'Montreal'
57+
df_toronto = pd.DataFrame(dict(number=[52, 36, 18, 14, 5], stage=stages))
58+
df_toronto['office'] = 'Toronto'
59+
df = pd.concat([df_mtl, df_toronto], axis=0)
60+
fig = px.funnel(df, x='number', y='stage', color='office')
61+
fig.show()
62+
```
63+
64+
### Basic Funnel Chart with graph_objects trace go.Funnel
65+
66+
If Plotly Express does not provide a good starting point, it is also possible to use the more generic `go.Funnel` function from `plotly.graph_objects`.
3367

3468
```python
3569
from plotly import graph_objects as go
@@ -60,7 +94,7 @@ fig = go.Figure(go.Funnel(
6094
fig.show()
6195
```
6296

63-
### Stacked Funnel Plot
97+
### Stacked Funnel Plot with go.Funnel
6498

6599
```python
66100
from plotly import graph_objects as go
@@ -92,7 +126,21 @@ fig.add_trace(go.Funnel(
92126
fig.show()
93127
```
94128

95-
#### Basic Area Funnel Plot
129+
### Basic Area Funnel Plot with plotly.express
130+
131+
With `px.funnel_area`, each row of the DataFrame is represented as a stage of
132+
the funnel.
133+
134+
```python
135+
import plotly.express as px
136+
fig = px.funnel_area(names=["The 1st","The 2nd", "The 3rd", "The 4th", "The 5th"],
137+
values=[5, 4, 3, 2, 1])
138+
fig.show()
139+
```
140+
141+
### Basic Area Funnel Plot with go.Funnelarea
142+
143+
If Plotly Express does not provide a good starting point, it is also possible to use the more generic `go.Funnelarea` function from `plotly.graph_objects`.
96144

97145
```python
98146
from plotly import graph_objects as go

Diff for: doc/python/heatmaps.md

+23-4
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.1'
9-
jupytext_version: 1.1.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.7
23+
version: 3.7.3
2424
plotly:
2525
description: How to make Heatmaps in Python with Plotly.
2626
display_as: scientific
@@ -34,7 +34,26 @@ jupyter:
3434
thumbnail: thumbnail/heatmap.jpg
3535
---
3636

37-
### Basic Heatmap
37+
### Heatmap with `plotly.express` and `px.imshow`
38+
39+
[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly. With `px.imshow`, each value of the input array is represented as a heatmap pixel.
40+
41+
`px.imshow` makes opiniated choices for representing heatmaps, such as using square pixels. To override this behaviour, you can use `fig.update_layout` or use the `go.Heatmap` trace from `plotly.graph_objects` as described below.
42+
43+
For more examples using `px.imshow`, see the [tutorial on displaying image data with plotly](/python/imshow).
44+
45+
```python
46+
import plotly.express as px
47+
48+
fig = px.imshow([[1, 20, 30],
49+
[20, 1, 60],
50+
[30, 60, 1]])
51+
fig.show()
52+
```
53+
54+
### Basic Heatmap with `plotly.graph_objects`
55+
56+
If Plotly Express does not provide a good starting point, it is also possible to use the more generic `go.Heatmap` function from `plotly.graph_objects`.
3857

3958
```python
4059
import plotly.graph_objects as go

Diff for: doc/python/mapbox-county-choropleth.md

+39-5
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.1'
9-
jupytext_version: 1.1.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 a Mapbox Choropleth Map of US Counties in Python with
2626
Plotly.
@@ -40,7 +40,9 @@ jupyter:
4040
To plot on Mapbox maps with Plotly you *may* need a Mapbox account and a public [Mapbox Access Token](https://www.mapbox.com/studio). See our [Mapbox Map Layers](/python/mapbox-layers/) documentation for more information.
4141

4242

43-
Making choropleth maps with `go.Choroplethmapbox` requires two main types of input: GeoJSON-formatted geometry information *where each `feature` has an `id`* and a list of values indexed by feature id. The GeoJSON data is passed to the `geojson` attribute, and the data is passed into the `z` attribute, in the same order as the IDs are passed into the `location` attribute.
43+
### Introduction: main parameters for choropleth mapbox charts
44+
45+
Making choropleth maps requires two main types of input: GeoJSON-formatted geometry information *where each `feature` has an `id`* and a list of values indexed by feature id. The GeoJSON data is passed to the `geojson` attribute, and the data is passed into the `z` (`color` for `px.choropleth_mapbox`) attribute, in the same order as the IDs are passed into the `location` attribute.
4446

4547

4648
#### GeoJSON with `feature.id`
@@ -67,7 +69,39 @@ df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/fips-
6769
df.head()
6870
```
6971

70-
#### Carto base map: no token needed
72+
### Choropleth map using plotly.express and carto base map (no token needed)
73+
74+
[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/).
75+
76+
With `px.choropleth_mapbox`, each row of the DataFrame is represented as a region of the choropleth.
77+
78+
```python
79+
from urllib.request import urlopen
80+
import json
81+
with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
82+
counties = json.load(response)
83+
84+
import pandas as pd
85+
df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/fips-unemp-16.csv",
86+
dtype={"fips": str})
87+
88+
import plotly.express as px
89+
90+
fig = px.choropleth_mapbox(df, geojson=counties, locations='fips', color='unemp',
91+
color_continuous_scale="Viridis",
92+
range_color=(0, 12),
93+
mapbox_style="carto-positron",
94+
zoom=3, center = {"lat": 37.0902, "lon": -95.7129},
95+
opacity=0.5,
96+
labels={'unemp':'unemployment rate'}
97+
)
98+
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
99+
fig.show()
100+
```
101+
102+
### Choropleth map using plotly.graph_objects and carto base map (no token needed)
103+
104+
If Plotly Express does not provide a good starting point, it is also possible to use the more generic `go.Choroplethmapbox` function from `plotly.graph_objects`.
71105

72106
```python
73107
from urllib.request import urlopen

Diff for: doc/python/mapbox-density-heatmaps.md

+26-7
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.1'
9-
jupytext_version: 1.1.1
8+
format_version: '1.2'
9+
jupytext_version: 1.3.0
1010
kernelspec:
1111
display_name: Python 3
1212
language: python
@@ -20,10 +20,9 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.6.7
23+
version: 3.7.3
2424
plotly:
25-
description: How to make a Mapbox Density Heatmap in Python
26-
with Plotly.
25+
description: How to make a Mapbox Density Heatmap in Python with Plotly.
2726
display_as: maps
2827
language: python
2928
layout: base
@@ -42,14 +41,34 @@ To plot on Mapbox maps with Plotly you *may* need a Mapbox account and a public
4241

4342

4443

45-
#### Stamen Terrain base map: no token needed
44+
### Stamen Terrain base map (no token needed): density mapbox with `plotly.express`
45+
46+
[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on "tidy" data](/python/px-arguments/).
47+
48+
With `px.density_mapbox`, each row of the DataFrame is represented as a point smoothed with a given radius of influence.
49+
50+
```python
51+
import pandas as pd
52+
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/earthquakes-23k.csv')
53+
54+
import plotly.express as px
55+
fig = px.density_mapbox(df, lat='Latitude', lon='Longitude', z='Magnitude', radius=10,
56+
center=dict(lat=0, lon=180), zoom=0,
57+
mapbox_style="stamen-terrain")
58+
fig.show()
59+
```
60+
61+
### Stamen Terrain base map (no token needed): density mapbox with `plotly.graph_objects`
62+
63+
If Plotly Express does not provide a good starting point, it is also possible to use the more generic `go.Densitymapbox` function from `plotly.graph_objects`.
4664

4765
```python
4866
import pandas as pd
4967
quakes = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/earthquakes-23k.csv')
5068

5169
import plotly.graph_objects as go
52-
fig = go.Figure(go.Densitymapbox(lat=quakes.Latitude, lon=quakes.Longitude, z=quakes.Magnitude, radius=10))
70+
fig = go.Figure(go.Densitymapbox(lat=quakes.Latitude, lon=quakes.Longitude, z=quakes.Magnitude,
71+
radius=10))
5372
fig.update_layout(mapbox_style="stamen-terrain", mapbox_center_lon=180)
5473
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
5574
fig.show()

0 commit comments

Comments
 (0)