I saw that, since Plotly 5.16, it is possible to add shapes to the legend, allowing to hide them by clicking on the legend item. However, I was unable to replicate this behavior when running the code example provided in Shapes in Python (and seen below). I am using Plotly 5.18 and tried to run this code both in a Jupyter Notebook and through a small Dash app. Neither of them worked: the plot looks as expected but the shape does not appear in the legend.
This functionality would be very useful for me so I really hope there is a way to fix this. Is it a known problem or does this code work for other people?
Yes, I am using:
jupyter-client==7.3.4
jupyter-core==4.11.1
However, I am facing the same issue when wrapping this figure in a small Dash app (Dash 2.11.1), see code below (ultimately, I am trying to use this feature in my Dash app):
So after testing with another Mac (where it worked), I ended up updating some other libraries and it seems that updating pandas fixed it? Not sure why this fixed this particular feature and why there were no errors hinting to this but Iβm happy nonetheless!
In case anyone else runs into this problem, I am now using: