Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable zoom in plotly choropleth mapbox plot with Python?

Here is my code:

fig = px.choropleth_mapbox(district_df[['District','Confirmed','Deaths','id','province']], geojson = geo_df, locations='id', color='Confirmed',
                           color_continuous_scale="Viridis",
                           mapbox_style="carto-positron",
                           zoom=5.9, hover_name = 'District',hover_data = {'District':False, 'Confirmed':True,'Deaths':True,'province':False,'id':False},
                           opacity=0.5, center = {"lat": 28.3949, "lon": 84.1240})

I would like to disable the zooming option. Is there a way?

like image 816
chillypowder Avatar asked Aug 10 '26 15:08

chillypowder


1 Answers

Yes, update_layout will do if you set dragmode=False.

https://community.plotly.com/t/map-graph-disable-scrollzoom-drag/9664

like image 66
KanDan Avatar answered Aug 13 '26 09:08

KanDan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!