plotly / plotly.py

The interactive graphing library for Python :sparkles: This project now includes Plotly Express!
https://plotly.com/python/
MIT License
16.31k stars 2.55k forks source link

Polar barplots do not have reset zoom available #3889

Open stephantamminga opened 2 years ago

stephantamminga commented 2 years ago

I'm creating polar barplots to visualize angular histograms. These plots do have a zoom option in the modebar, but not a resetScale or zoomout. So I can zoom in, but there is no way to zoom out again.

Trying to add these buttons explicitly doesn't work. The modebar_add function does not throw an error, but no buttons are added either.

import plotly.graph_objects as go
import numpy as np

fig = go.Figure()

bins = np.linspace(0,358,180)
arr = np.array(bins)

series = [90+20*np.random.normal() for _ in np.arange(100)]

count, division = np.histogram(series, bins=bins)

fig.add_trace(go.Barpolar(
    r=count,
    theta=series,
    width=1,
    marker_line_width=2,
    opacity=0.5,
    base=0
))

fig.update_layout(
    title='Polar histogram',
    width=1000,
    height=1000,
    template=None,
    polar = dict(
        angularaxis = dict(showticklabels=True,
                           ticks='',
                           ),
    ),
    modebar_add=['resetScale',
                 'zoomout'],
)

fig.show()
matinh commented 1 week ago

This is not only true for charts of type barplot but also for scatterpolar charts. Same behavior as described above. Tested with Plotly.js 2.35.2.