Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update plotly.js version to "2.27.1" #4417

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 31 additions & 13 deletions doc/python/mapbox-density-heatmaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ jupyter:
text_representation:
extension: .md
format_name: markdown
format_version: '1.2'
jupytext_version: 1.3.0
format_version: '1.3'
jupytext_version: 1.15.1
kernelspec:
display_name: Python 3
display_name: Python 3 (ipykernel)
language: python
name: python3
language_info:
Expand All @@ -20,7 +20,7 @@ jupyter:
name: python
nbconvert_exporter: python
pygments_lexer: ipython3
version: 3.7.3
version: 3.10.4
plotly:
description: How to make a Mapbox Density Heatmap in Python with Plotly.
display_as: maps
Expand All @@ -33,42 +33,60 @@ jupyter:
thumbnail: thumbnail/mapbox-density.png
---

#### Mapbox Access Token

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.

### Stamen Terrain base map (no token needed): density mapbox with `plotly.express`
### Stamen Terrain base map (Stadia Maps token needed): density mapbox with `plotly.express`

[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on a variety of types of data](/python/px-arguments/) and produces [easy-to-style figures](/python/styling-plotly-express/).

With `px.density_mapbox`, each row of the DataFrame is represented as a point smoothed with a given radius of influence.

To use the mapbox_style "stamen-terrain", you'll need a [Stadia Maps](https://www.stadiamaps.com) token, which you can provide to the `mapbox_accesstoken` parameter on `fig.update_layout`.

Here, we have the token saved in a file called `.mapbox_token`, load it in to the variable `token`, and then pass it to `mapbox_accesstoken`.

<!-- #region -->
```python
import plotly.express as px
import pandas as pd

token = open(".mapbox_token").read() # you will need your own token

df = pd.read_csv('https://github.com/raw/plotly/datasets/master/earthquakes-23k.csv')

import plotly.express as px
fig = px.density_mapbox(df, lat='Latitude', lon='Longitude', z='Magnitude', radius=10,
center=dict(lat=0, lon=180), zoom=0,
mapbox_style="stamen-terrain")
fig.update_layout(mapbox_accesstoken=token)
fig.show()
```
<!-- #endregion -->

![Stamen terrain Plotly Express example](https://github.com/raw/plotly/documentation/gh-pages/all_static/images/stamen-terrain-1.jpeg)

### Stamen Terrain base map (no token needed): density mapbox with `plotly.graph_objects`

### Stamen Terrain base map (Stadia Maps token needed): density mapbox with `plotly.graph_objects`

If Plotly Express does not provide a good starting point, it is also possible to use [the more generic `go.Densitymapbox` class from `plotly.graph_objects`](/python/graph-objects/).

<!-- #region -->
```python
import plotly.graph_objects as go
import pandas as pd

token = open(".mapbox_token").read() # you will need your own token

quakes = pd.read_csv('https://github.com/raw/plotly/datasets/master/earthquakes-23k.csv')

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

```
<!-- #endregion -->

![Stamen terrain Graph Objects example](https://github.com/raw/plotly/documentation/gh-pages/all_static/images/stamen-terrain-2.jpeg)


#### Reference

Expand Down
14 changes: 7 additions & 7 deletions packages/javascript/jupyterlab-plotly/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/javascript/jupyterlab-plotly/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@lumino/messaging": "^1.2.3",
"@lumino/widgets": "^1.8.1",
"lodash": "^4.17.4",
"plotly.js": "^2.27.0"
"plotly.js": "^2.27.1"
},
"jupyterlab": {
"extension": "lib/jupyterlab-plugin",
Expand Down
2 changes: 1 addition & 1 deletion packages/python/plotly/plotly/offline/_plotlyjs_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# DO NOT EDIT
# This file is generated by the updatebundle setup.py command
__plotlyjs_version__ = "2.27.0"
__plotlyjs_version__ = "2.27.1"
4 changes: 2 additions & 2 deletions packages/python/plotly/plotly/package_data/plotly.min.js

Large diffs are not rendered by default.