@@ -5,10 +5,10 @@ jupyter:
5
5
text_representation :
6
6
extension : .md
7
7
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
10
10
kernelspec :
11
- display_name : Python 3
11
+ display_name : Python 3 (ipykernel)
12
12
language : python
13
13
name : python3
14
14
language_info :
@@ -20,7 +20,7 @@ jupyter:
20
20
name : python
21
21
nbconvert_exporter : python
22
22
pygments_lexer : ipython3
23
- version : 3.6.8
23
+ version : 3.8.0
24
24
plotly :
25
25
description : How to make Mapbox maps in Python with various base layers, with
26
26
or without needing a Mapbox Access token.
@@ -192,6 +192,26 @@ fig.show()
192
192
193
193
See the example in the [ plotly and datashader tutorial] ( /python/datashader ) .
194
194
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
+
195
215
#### Reference
196
216
197
217
See https://plotly.com/python/reference/layout/mapbox/ for more information and options!
0 commit comments