@@ -81,27 +81,6 @@ fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
81
81
fig.show()
82
82
```
83
83
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
- ```
105
84
106
85
<!-- #region -->
107
86
#### 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
123
102
import plotly.express as px
124
103
125
104
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 )
127
106
fig.update_layout(
128
107
mapbox_style = " white-bg" ,
129
108
mapbox_layers = [
@@ -153,7 +132,7 @@ us_cities = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/maste
153
132
import plotly.express as px
154
133
155
134
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 )
157
136
fig.update_layout(
158
137
mapbox_style = " white-bg" ,
159
138
mapbox_layers = [
@@ -175,5 +154,29 @@ fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
175
154
fig.show()
176
155
```
177
156
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
+
178
181
#### Reference
179
182
See https://plot.ly/python/reference/#layout-mapbox for more information and options!
0 commit comments