-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fix add hline not working for make_subplot if not populated #5254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…5/plotly.py into fix-add_hline-not-working
…rors This reverts commit b92a744.
|
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. |
|
Hi @Erikp15, it seems to me that the What I would recommend, if you don't want to exclude empty subplots, is to pass |
This is a proposal fix for issue #5136
I first reproduced the issue and created two unit tests,
test_add_hline_empty_subplots.pyandtest_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 withexclude_empty_subplots=True. For a freshmake_subplotsfigure, 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_vlineare invoked and the figure contains no traces (len(self.data)==0), the code now disables the exclude empty subplots logic before delegating toadd_shape, allowing the shape to be created and later displayed once data is added.Code PR
plotly.graph_objects, my modifications concern the code generator and not the generated files.