-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
fix quiver3d incorrect arrow colors #27754
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
As an aside, at first I tried to run pytest "in the root directory of my development repository" (e.g.
I later got the test working by running pytest in |
It is possible to set a |
- (avoid unnecessary computation otherwise)
Thank you for the input! I've edited the test case accordingly. |
Hi, bumping this for review. I think this is a pretty minor change that makes a big difference, since as of now, attempting to color-code quiver3d arrows doesn't work without a convoluted work-around that requires people to understand the internals of quiver3d. Judging by Stack Overflow, it's something a lot of people (including me) run into. I've pasted a before and after image below in case that's necessary. I think the fix as presented in this PR would cover 99% of all use cases (i.e., the length of the color list being the same length as the number of quiver arrows being plotted). Only in some edgecase where the length of the list of colors is not an even divisor of the length of the list of arrows would the old behavior revert, where arrowheads have a different color than their bodies. If this edge-case needs to be covered, an alternative solution would be to construct a single line for each arrow (shaft and each head included), as I tried on another branch. This requires drawing the same line twice (i.e. arrow tip to the end of one head, back to an arrow tip, to the end of another head), and it results in a minor, but visible, change to the look of the arrowhead. It also changes the number of lines that are returned. Thank you for your time! |
As a quick confirmation, without the time to look into the code: This approach is to be preferred over the single line due to back compatibility. |
Hi @AlecVercruysse, these changes look good to me. Could you add another image test for this behavior so we catch future regressions? The one in your most recent comment looks like a good example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the CI tests pass, this looks good to me for merge. Congratulations @AlecVercruysse on your first contribution to matplotlib, and thank you for implementing this fix! We welcome future improvements and hope to see more of you!
Once this is merged in, I'd recommend linking to this PR in a new stackoverflow answer, and saying which matplotlib version this will be available in.
@scottshambaugh Thank you! To confirm, this will appear in 3.8.4? |
Yes, this is a bugfix and has no API changes so I think this is appropriate for a patch release. |
Update figure test image
…754-on-v3.8.x Backport PR #27754 on branch v3.8.x (fix quiver3d incorrect arrow colors)
PR summary
Closes #11759, which identifies that when setting individual arrow colors of a quiver3d plot, the arrow heads are colored incorrectly (differently than the bodies). PR #13742 attempted to address this issue but is now stale.
The default cycling logic in LineCollection should be good enough to handle the logic of assigning the correct property to each line (body, head 1, head 2) in an arrow. I switched the order that the lines were passed to the Line3DCollection to make use of this cycling. I also removed the logic that got rid of length 0 lines, since that messed up cycling (e.g., in the example below, only 9 lines are plotted but 10 colors are provided).
I filled out the below checklist with the idea that no changes need to be made to examples or documentation, as this is a bugfix. Running
pytest test_quiver.py
inmatplotlib/lib/matplotlib/tests
passes.Thank you for reviewing!
PR checklist