vline
and hline
visibility not updated by custom buttons
#5120
Labels
vline
and hline
visibility not updated by custom buttons
#5120
Hello,
Summary
Visibility of
vline
andhline
objects do not update through custom buttons as expected. When working with custom buttons, the user can control the visibility for most traces through a list in the button dictionary. However this will not update the visibility of traces added throughfig.add_vline
orfig.add_hline
.Example
This example is a modification of one in the documentation. We expect the horizontal line to be visible unless the user selects None, and the vertical line to be visible when the user selects Both.
Despite seemingly setting visibility for the vertical line and horizontal line in the button dictionary, the horizontal line remains visible and vertical line not visible regardless of button selected. See relevant image of example below:
Speculation
Upon further inspection, it appears this is because
fig.add_vline
andfig.add_hline
are adding shapes, which behave differently to standard traces. Therefore updating these requires defining the shapes in the custom buttons rather than adding them to the figure and then attempting to control visibility. The below example achieves the intended behaviour.If this is the case, it could be better documented. While the existing documentation suggests this behaviour for annotations, it seems reasonable to expect lines to behave more like traces than annotations, particularly because they do take a visible argument. Maybe it would be best to update the documentation for this yahoo example to show averages using a shape (as shown in the code above), rather than a trace.
Happy to help improve the documentation if this appears to be the best approach. Sorry if this has already been reported earlier.
Thanks!
The text was updated successfully, but these errors were encountered: