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
Copy file name to clipboardExpand all lines: doc/python/mapbox-density-heatmaps.md
+53-8Lines changed: 53 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -5,10 +5,10 @@ jupyter:
5
5
text_representation:
6
6
extension: .md
7
7
format_name: markdown
8
-
format_version: '1.2'
9
-
jupytext_version: 1.3.0
8
+
format_version: '1.3'
9
+
jupytext_version: 1.14.6
10
10
kernelspec:
11
-
display_name: Python 3
11
+
display_name: Python 3 (ipykernel)
12
12
language: python
13
13
name: python3
14
14
language_info:
@@ -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.10.11
24
24
plotly:
25
25
description: How to make a Mapbox Density Heatmap in Python with Plotly.
26
26
display_as: maps
@@ -35,9 +35,10 @@ jupyter:
35
35
36
36
#### Mapbox Access Token
37
37
38
-
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.
38
+
To plot on Mapbox maps with Plotly, you may need a [Mapbox account and token](https://www.mapbox.com/studio) or a [Stadia Maps account and token](https://www.stadiamaps.com), depending on base map (`mapbox_style`) you use. On this page, we show how to use the "open-street-map" base map, which doesn't require a token, and a "stamen" base map, which requires a Stadia Maps token. See our [Mapbox Map Layers](/python/mapbox-layers/) documentation for more examples.
39
39
40
-
### Stamen Terrain base map (no token needed): density mapbox with `plotly.express`
40
+
41
+
### OpenStreetMap base map (no token needed): density mapbox with `plotly.express`
41
42
42
43
[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/).
### Stamen Terrain base map (Stadia Maps token needed): density mapbox with `plotly.express`
60
+
61
+
Some base maps require a token. To use "stamen" base maps, 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`.
62
+
63
+
```python
64
+
import plotly.express as px
65
+
import pandas as pd
66
+
67
+
token =open(".mapbox_token").read() # you will need your own token
### Stamen Terrain base map (no token needed): density mapbox with `plotly.graph_objects`
78
+
<!-- #endregion -->
79
+
80
+
### OpenStreetMap base map (no token needed): density mapbox with `plotly.graph_objects`
58
81
59
82
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/).
### Stamen Terrain base map (Stadia Maps token needed): density mapbox with `plotly.graph_objects`
98
+
99
+
Some base maps require a token. To use "stamen" base maps, 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`.
100
+
101
+
102
+
```python
103
+
import plotly.graph_objects as go
104
+
import pandas as pd
105
+
106
+
token =open(".mapbox_token").read() # you will need your own token
0 commit comments