Skip to content

Commit 7040a57

Browse files
Merge branch 'master' into select-traces-function-selector
2 parents 7c73aef + 54efc64 commit 7040a57

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2894
-1604
lines changed

Diff for: .circleci/config.yml

+9
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,15 @@ jobs:
440440
git push --force [email protected]:plotly/plotly.py-docs.git master:built
441441
rm -rf .git
442442
cd ../..
443+
cd build/ipynb
444+
git init
445+
git config user.name plotlydocbot
446+
git config user.email [email protected]
447+
git add *
448+
git commit -m "build of https://github.com/plotly/plotly.py/commit/${CIRCLE_SHA1}"
449+
git push --force [email protected]:plotly/plotly.py-docs.git master:built_ipynb
450+
rm -rf .git
451+
cd ../..
443452
fi
444453
tar -zcf build/html.tgz build/html
445454
rm -rf build/html build/ipynb

Diff for: CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [4.12.0] - unreleased
6+
7+
### Updated
8+
9+
- Updated Plotly.js to version 1.57.0. See the [plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/v1.57.0/CHANGELOG.md) for more information. These changes are reflected in the auto-generated `plotly.graph_objects` module.
10+
511
## [4.11.0] - 2020-10-01
612

713
### Updated

Diff for: README.md

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
</tr>
3232
</table>
3333

34+
## Data Science Workspaces
35+
36+
Our recommended IDE for Plotly’s Python graphing library is Dash Enterprise’s [Data Science Workspaces](https://plotly.com/dash/workspaces/), which has both Jupyter notebook and Python code file support.
37+
3438
## Quickstart
3539

3640
`pip install plotly==4.11.0`

Diff for: binder/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ cufflinks==0.17.3
1818
kaleido
1919
scikit-learn
2020
umap-learn
21+
wget

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

+50
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,56 @@ fig = go.Figure(data=[go.Bar(
287287
fig.show()
288288
```
289289

290+
Bar charts with custom widths can be used to make mekko charts (also known as marimekko charts, mosaic plots, or variwide charts).
291+
292+
```python
293+
import plotly.graph_objects as go
294+
import numpy as np
295+
296+
labels = ["apples","oranges","pears","bananas"]
297+
widths = np.array([10,20,20,50])
298+
299+
data = {
300+
"South": [50,80,60,70],
301+
"North": [50,20,40,30]
302+
}
303+
304+
fig = go.Figure()
305+
for key in data:
306+
fig.add_trace(go.Bar(
307+
name=key,
308+
y=data[key],
309+
x=np.cumsum(widths)-widths,
310+
width=widths,
311+
offset=0,
312+
customdata=np.transpose([labels, widths*data[key]]),
313+
texttemplate="%{y} x %{width} =<br>%{customdata[1]}",
314+
textposition="inside",
315+
textangle=0,
316+
textfont_color="white",
317+
hovertemplate="<br>".join([
318+
"label: %{customdata[0]}",
319+
"width: %{width}",
320+
"height: %{y}",
321+
"area: %{customdata[1]}",
322+
])
323+
))
324+
325+
fig.update_xaxes(
326+
tickvals=np.cumsum(widths)-widths/2,
327+
ticktext= ["%s<br>%d" % (l, w) for l, w in zip(labels, widths)]
328+
)
329+
330+
fig.update_xaxes(range=[0,100])
331+
fig.update_yaxes(range=[0,100])
332+
333+
fig.update_layout(
334+
title_text="Marimekko Chart",
335+
barmode="stack",
336+
uniformtext=dict(mode="hide", minsize=10),
337+
)
338+
```
339+
290340
### Customizing Individual Bar Base
291341

292342
```python

Diff for: doc/python/choropleth-maps.md

+21-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.2'
9-
jupytext_version: 1.3.1
9+
jupytext_version: 1.4.2
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.7
2424
plotly:
2525
description: How to make choropleth maps in Python with Plotly.
2626
display_as: maps
@@ -164,7 +164,25 @@ fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
164164
fig.show()
165165
```
166166

167-
<!-- #region -->
167+
### Using GeoPandas Data Frames
168+
169+
`px.choropleth` accepts the `geometry` of a [GeoPandas](https://geopandas.org/) data frame as the input to `geojson` if the `geometry` contains polygons.
170+
171+
```python
172+
import plotly.express as px
173+
import geopandas as gpd
174+
175+
geo_df = gpd.read_file(gpd.datasets.get_path('nybb')).to_crs("EPSG:4326")
176+
177+
fig = px.choropleth(geo_df,
178+
geojson=geo_df.geometry,
179+
locations=geo_df.index,
180+
color='Shape_Leng',
181+
hover_name="BoroName")
182+
fig.update_geos(fitbounds="locations", visible=False)
183+
fig.show()
184+
```
185+
168186

169187
### Using Built-in Country and State Geometries
170188

@@ -179,7 +197,6 @@ Plotly comes with two built-in geometries which do not require an external GeoJS
179197
180198
To use the built-in countries geometry, provide `locations` as [three-letter ISO country codes](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3).
181199

182-
<!-- #endregion -->
183200

184201
```python
185202
import plotly.express as px

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

+24-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.2'
9-
jupytext_version: 1.3.1
9+
jupytext_version: 1.4.2
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.7
2424
plotly:
2525
description: How to make a Mapbox Choropleth Map of US Counties in Python with
2626
Plotly.
@@ -157,6 +157,27 @@ fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
157157
fig.show()
158158
```
159159

160+
### Using GeoPandas Data Frames
161+
162+
`px.choropleth_mapbox` accepts the `geometry` of a [GeoPandas](https://geopandas.org/) data frame as the input to `geojson` if the `geometry` contains polygons.
163+
164+
```python
165+
import plotly.express as px
166+
import geopandas as gpd
167+
168+
geo_df = gpd.read_file(gpd.datasets.get_path('nybb')).to_crs("EPSG:4326")
169+
170+
fig = px.choropleth_mapbox(geo_df,
171+
geojson=geo_df.geometry,
172+
locations=geo_df.index,
173+
color='Shape_Leng',
174+
hover_name="BoroName",
175+
center={"lat": 40.71, "lon": -74.00},
176+
mapbox_style="open-street-map",
177+
zoom=8)
178+
fig.show()
179+
```
180+
160181
### Choropleth map using plotly.graph_objects and carto base map (no token needed)
161182

162183
If Plotly Express does not provide a good starting point, it is also possible to use [the more generic `go.Choroplethmapbox` class from `plotly.graph_objects`](/python/graph-objects/).
@@ -209,4 +230,4 @@ fig.show()
209230

210231
#### Reference
211232

212-
See https://plotly.com/python/reference/choroplethmapbox/ for more information about mapbox and their attribute options.
233+
See https://plotly.com/python/reference/choroplethmapbox/ for more information about mapbox and their attribute options.

Diff for: doc/python/scatter-plots-on-maps.md

+21-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.1'
9-
jupytext_version: 1.1.1
8+
format_version: '1.2'
9+
jupytext_version: 1.4.2
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.7
2424
plotly:
2525
description: How to make scatter plots on maps in Python. Scatter plots on maps
2626
highlight geographic areas and can be colored by value.
@@ -66,6 +66,24 @@ fig = px.scatter_geo(df, locations="iso_alpha",
6666
fig.show()
6767
```
6868

69+
### Basic Example with GeoPandas
70+
71+
`px.scatter_geo` can work well with [GeoPandas](https://geopandas.org/) dataframes whose `geometry` is of type `Point`.
72+
73+
```python
74+
import plotly.express as px
75+
import geopandas as gpd
76+
77+
geo_df = gpd.read_file(gpd.datasets.get_path('naturalearth_cities'))
78+
79+
px.set_mapbox_access_token(open(".mapbox_token").read())
80+
fig = px.scatter_geo(geo_df,
81+
lat=geo_df.geometry.y,
82+
lon=geo_df.geometry.x,
83+
hover_name="name")
84+
fig.show()
85+
```
86+
6987
### U.S. Airports Map
7088

7189
Here we show how to use `go.Scattergeo` from `plotly.graph_objects`.

Diff for: doc/python/scattermapbox.md

+22-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.2'
9-
jupytext_version: 1.3.2
9+
jupytext_version: 1.4.2
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.7.3
23+
version: 3.7.7
2424
plotly:
2525
description: How to make scatter plots on Mapbox maps in Python.
2626
display_as: maps
@@ -52,6 +52,25 @@ fig = px.scatter_mapbox(df, lat="centroid_lat", lon="centroid_lon", color="p
5252
fig.show()
5353
```
5454

55+
### Basic Example with GeoPandas
56+
57+
`px.scatter_mapbox` can work well with [GeoPandas](https://geopandas.org/) dataframes whose `geometry` is of type `Point`.
58+
59+
```python
60+
import plotly.express as px
61+
import geopandas as gpd
62+
63+
geo_df = gpd.read_file(gpd.datasets.get_path('naturalearth_cities'))
64+
65+
px.set_mapbox_access_token(open(".mapbox_token").read())
66+
fig = px.scatter_mapbox(geo_df,
67+
lat=geo_df.geometry.y,
68+
lon=geo_df.geometry.x,
69+
hover_name="name",
70+
zoom=1)
71+
fig.show()
72+
```
73+
5574
#### Basic Example
5675

5776
```python
@@ -228,4 +247,4 @@ fig.show()
228247

229248
#### Reference
230249

231-
See https://plotly.com/python/reference/scattermapbox/ for more information and options!
250+
See https://plotly.com/python/reference/scattermapbox/ for more information and options!

Diff for: doc/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ pyarrow
2828
cufflinks==0.17.3
2929
kaleido
3030
umap-learn
31+
wget

Diff for: packages/javascript/plotlywidget/package-lock.json

+22-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)