@@ -193,22 +193,32 @@ fig.show()
193193See the example in the [ plotly and datashader tutorial] ( /python/datashader ) .
194194
195195
196- #### Setting Bounds for Panning and Zooming
196+ #### Setting Map Bounds
197197
198198Set 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 ` .
200200
201201``` 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-
205202import plotly.express as px
203+ import pandas as pd
206204
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+ )
209219fig.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 })
212222fig.show()
213223```
214224
0 commit comments