@@ -5,10 +5,10 @@ jupyter:
55 text_representation :
66 extension : .md
77 format_name : markdown
8- format_version : ' 1.2 '
9- jupytext_version : 1.3 .1
8+ format_version : ' 1.3 '
9+ jupytext_version : 1.14 .1
1010 kernelspec :
11- display_name : Python 3
11+ display_name : Python 3 (ipykernel)
1212 language : python
1313 name : python3
1414 language_info :
@@ -20,7 +20,7 @@ jupyter:
2020 name : python
2121 nbconvert_exporter : python
2222 pygments_lexer : ipython3
23- version : 3.6.8
23+ version : 3.8.0
2424 plotly :
2525 description : How to make Mapbox maps in Python with various base layers, with
2626 or without needing a Mapbox Access token.
@@ -192,6 +192,26 @@ fig.show()
192192
193193See the example in the [ plotly and datashader tutorial] ( /python/datashader ) .
194194
195+
196+ #### Setting Bounds for Panning and Zooming
197+
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 ` .
200+
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+ import plotly.express as px
206+
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 )
209+ 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 })
212+ fig.show()
213+ ```
214+
195215#### Reference
196216
197217See https://plotly.com/python/reference/layout/mapbox/ for more information and options!
0 commit comments