Sorry, something went wrong.
|
Hi @gvwilson , just checking in to see if there's anything else needed from my end on this PR. Happy to make any changes if needed. |
Sorry, something went wrong.
|
Hi @Erikp15, it seems to me that the exclude_empty_subplots argument is working as intended (i.e., it indeed does not draw the hline if the subplot is empty), so I'm not sure we want to change that behavior. What I would recommend, if you don't want to exclude empty subplots, is to pass exclude_empty_subplots=False to add_hline() — would that work for you? |
Sorry, something went wrong.
This is a proposal fix for issue #5136
I first reproduced the issue and created two unit tests, test_add_hline_empty_subplots.py and test_hline_subplots_bug.py, that check if the bug is resolved. Then I implemented the fix (outlined below), which passed both of the new unit tests, and in the process, no old tests were broken.
Root cause
add_shape() is called with exclude_empty_subplots=True. For a fresh make_subplots figure, every subplot is flagged empty, so the h/v line shape is filtered out and never appears, even after traces are later added.
Fix overview
When add_hline/add_vline are invoked and the figure contains no traces (len(self.data)==0), the code now disables the exclude empty subplots logic before delegating to add_shape, allowing the shape to be created and later displayed once data is added.
Code PR