Conversation
…p cells With animation_frame and facet_col_wrap, fig.data kept every trace whose index was below nrows * ncols. When the facets do not fill the wrapped grid, the first facet of the second animation frame was drawn in the empty cell and stayed there during the animation. Only the first frame's facets are added to fig.data now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue
No existing issue that I could find (searched open and closed issues and PRs for
imshow facet_col_wrapandimshow animation facet). I'm happy to open one first if you'd like it tracked separately.Description of change
px.imshowwith bothanimation_frameandfacet_col_wrapdraws the wrong image when the facets don't fill the wrapped grid. The loop that buildsfig.datakept every trace withindex < nrows * ncols. With 5 facets wrapped at 2 columns that is 6, so trace 5, which is facet 0 of the second animation frame, went into the empty sixth cell. Frames only update the first 5 traces, so that extra image stays there for the whole animation, with no facet title. The check now usesnslices_facets, the number of facets in one frame.Demo
Before:
6 ('5', 'x2', 60.0). Frame 1's first facet (values starting at 60) is drawn in the bottom-right cell, which should be empty.After:
5 ('4', 'x', 48.0). Only frame 0's five facets are drawn, and the sixth cell is empty.Testing strategy
I added
test_animation_and_facet_col_wrap_incomplete_gridtotests/test_optional/test_px/test_imshow.py, covering bothbinary_string=False(Heatmap) andTrue(Image). Both cases fail onmain(6 traces instead of 5) and pass with this change. The fulltest_imshow.pypasses (92 tests), andruff format --checkis clean.Additional information (optional)
Without animation there is only one frame's worth of traces, so the old bound had no effect. With
facet_row, orfacet_colwithout wrapping,nrows * ncolsalready equals the facet count, so only the wrapped layout with an incomplete last row was affected. I found this bug and wrote the fix with the help of an AI coding assistant, and I checked the change and the test output myself.Guidelines