@@ -193,22 +193,32 @@ fig.show()
193
193
See the example in the [ plotly and datashader tutorial] ( /python/datashader ) .
194
194
195
195
196
- #### Setting Bounds for Panning and Zooming
196
+ #### Setting Map Bounds
197
197
198
198
Set bounds for a map to specify an area outside which a user interacting with the map can't pan or zoom. Here we
199
- set a maximum longitude of ` -180 ` , a minimum longitude of ` -50 ` , a maximum latitude as ` 90 ` , and a minimum latitude of ` 20 ` .
199
+ set a maximum longitude of ` -180 ` , a minimum longitude of ` -50 ` , a maximum latitude of ` 90 ` , and a minimum latitude of ` 20 ` .
200
200
201
201
``` python
202
- import pandas as pd
203
- us_cities = pd.read_csv(" https://raw.githubusercontent.com/plotly/datasets/master/us-cities-top-1k.csv" )
204
-
205
202
import plotly.express as px
203
+ import pandas as pd
206
204
207
- fig = px.scatter_mapbox(us_cities, lat = " lat" , lon = " lon" , hover_name = " City" , hover_data = [" State" , " Population" ],
208
- color_discrete_sequence = [" fuchsia" ], zoom = 3 , height = 300 )
205
+ us_cities = pd.read_csv(
206
+ " https://raw.githubusercontent.com/plotly/datasets/master/us-cities-top-1k.csv"
207
+ )
208
+
209
+ fig = px.scatter_mapbox(
210
+ us_cities,
211
+ lat = " lat" ,
212
+ lon = " lon" ,
213
+ hover_name = " City" ,
214
+ hover_data = [" State" , " Population" ],
215
+ color_discrete_sequence = [" fuchsia" ],
216
+ zoom = 3 ,
217
+ height = 300 ,
218
+ )
209
219
fig.update_layout(mapbox_style = " open-street-map" )
210
- fig.update_layout(margin = {" r" :0 , " t" :0 , " l" :0 , " b" :0 })
211
- fig.update_layout(mapbox_bounds = {" west" :- 180 , " east" :- 50 , " south" :20 , " north" :90 })
220
+ fig.update_layout(margin = {" r" : 0 , " t" : 0 , " l" : 0 , " b" : 0 })
221
+ fig.update_layout(mapbox_bounds = {" west" : - 180 , " east" : - 50 , " south" : 20 , " north" : 90 })
212
222
fig.show()
213
223
```
214
224
0 commit comments