在plotly网站Map Configuration and Styling in Python中描述了如何自动缩放“地理地图”:
import plotly.express as px
fig = px.line_geo(lat=[0,15,20,35], lon=[5,10,25,30]) # Creates a "Geo map" figure
fig.update_geos(fitbounds="locations") # Automatic Zooming !!!!
fig.show()
Run Code Online (Sandbox Code Playgroud)
这有效,而且如果我尝试在“Mapbox 地图”上进行相同的操作,它不会应用自动缩放:
fig = px.scatter_mapbox(filtered_df, lat="latitude", lon="longitude", color="ID") # Creates a "Mapbox map" figure
fig.update_layout(mapbox_style="open-street-map")
fig.update_geos(fitbounds="locations") # Automatic Zooming not working!!!
Run Code Online (Sandbox Code Playgroud)
在 Python 的 Mapbox 地图图层中没有如何执行此操作的信息。