Can I set the default zoom level for mapbox plots in a template? I have the following example code:
# Import
import plotly.express as px
from plotly import io as pio, __version__ as pver
# Show version
print(f"plotly version: {pver}")
# Create dummy data
lat = [52.37726, 52.3772, 52.375927, 52.375809, 52.37568, 52.37536, 52.37521, 52.37495]
lon = [4.90079, 4.901705, 4.904613, 4.9048, 4.905146, 4.90588, 4.906141, 4.90661]
# Show plot
fig = px.scatter_mapbox(lat=lat, lon=lon, mapbox_style="open-street-map", title="Default zoom")
fig.show()
fig.layout.mapbox
Now if I set the mapbox properties in the template, my expectation would be that that would be reflected in the plot:
# Adjust zoom level in template
pio.templates["plotly"].layout.mapbox.zoom = 13
fig_template = px.scatter_mapbox(lat=lat, lon=lon, mapbox_style="open-street-map", title="Zoom from template", template="plotly")
fig_template.show()
fig_template.layout.mapbox
Adjust another property of the template, e.g. the margin, does work, although I donβt see the values being reflected in the layout object:
pio.templates["plotly"].layout.margin = dict(l=0, r=0, t=0, b=0)
fig_template = px.scatter_mapbox(lat=lat, lon=lon, mapbox_style="open-street-map", title="No margin", template="plotly")
fig_template.show()
fig_template.layout
How can I set a mapbox property in a template?
Ideally I would be able to set the zoom, center and style properties in a template and re-use that, such that I donβt have to set it for each plot.