Skip to content

Commit 454f273

Browse files
fix dark example
1 parent b01917d commit 454f273

File tree

1 file changed

+26
-23
lines changed

1 file changed

+26
-23
lines changed

python/mapbox-layers.md

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -81,27 +81,6 @@ fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
8181
fig.show()
8282
```
8383

84-
<!-- #region -->
85-
#### Dark tiles from Mapbox service: free token needed
86-
87-
88-
Here is the same map rendered with the `"dark"` style from the Mapbox service, which requires an Access Token:
89-
<!-- #endregion -->
90-
91-
```python
92-
token = open(".mapbox_token").read() # you will need your own token
93-
94-
import pandas as pd
95-
us_cities = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/us-cities-top-1k.csv")
96-
97-
import plotly.express as px
98-
99-
fig = px.scatter_mapbox(us_cities, lat="lat", lon="lon", hover_name="City", hover_data=["State", "Population"],
100-
color_discrete_sequence=["fuchsia"], zoom=3, height=300)
101-
fig.update_layout(mapbox_style="dark", mapbox_accesstoken=token)
102-
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
103-
fig.show()
104-
```
10584

10685
<!-- #region -->
10786
#### Using `layout.mapbox.layers` to Specify a Base Map
@@ -123,7 +102,7 @@ us_cities = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/maste
123102
import plotly.express as px
124103

125104
fig = px.scatter_mapbox(us_cities, lat="lat", lon="lon", hover_name="City", hover_data=["State", "Population"],
126-
color_discrete_sequence=["fuchsia"], zoom=3)
105+
color_discrete_sequence=["fuchsia"], zoom=3, height=300)
127106
fig.update_layout(
128107
mapbox_style="white-bg",
129108
mapbox_layers=[
@@ -153,7 +132,7 @@ us_cities = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/maste
153132
import plotly.express as px
154133

155134
fig = px.scatter_mapbox(us_cities, lat="lat", lon="lon", hover_name="City", hover_data=["State", "Population"],
156-
color_discrete_sequence=["fuchsia"], zoom=3)
135+
color_discrete_sequence=["fuchsia"], zoom=3, height=300)
157136
fig.update_layout(
158137
mapbox_style="white-bg",
159138
mapbox_layers=[
@@ -175,5 +154,29 @@ fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
175154
fig.show()
176155
```
177156

157+
158+
<!-- #region -->
159+
#### Dark tiles from Mapbox service: free token needed
160+
161+
162+
Here is a map rendered with the `"dark"` style from the Mapbox service, which requires an Access Token:
163+
164+
<!-- #endregion -->
165+
166+
```python
167+
token = open(".mapbox_token").read() # you will need your own token
168+
169+
import pandas as pd
170+
us_cities = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/us-cities-top-1k.csv")
171+
172+
import plotly.express as px
173+
174+
fig = px.scatter_mapbox(us_cities, lat="lat", lon="lon", hover_name="City", hover_data=["State", "Population"],
175+
color_discrete_sequence=["fuchsia"], zoom=3, height=300)
176+
fig.update_layout(mapbox_style="dark", mapbox_accesstoken=token)
177+
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
178+
fig.show()
179+
```
180+
178181
#### Reference
179182
See https://plot.ly/python/reference/#layout-mapbox for more information and options!

0 commit comments

Comments
 (0)