-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Connect stream lines if no varying width or color #25112
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
Streamplot segments stream lines into small pieces of lines in order to have different width and colors from each other. However, by doing the segmentation the connection of lines are getting lost. The loss of connection introduces visible gaps. This commit avoids unnecessary segmentation of a streamline into smaller lines if there is no need to do so. Fixing the problem only for non-varying width and color stream plots.
Thank you for picking this up @gokberkgunes ! We are going to have to regenerate a bunch of test images (I do not think it is worth putting a back-compat flag in for this). It will also need a behavior change note |
It's actually surprisingly few images that need to be remade, it seems (at least there are only 4 tests that fail), but still, we will need to regenerate those. |
I am not very experienced with tests. I have read the documentation and checked some other pull requests. Before going further I wanted to ask you if what I am thinking is correct or not. So, should I directly regenerate and replace at least the failing streamplot test images which are in |
Hi @gokberkgunes yes, please replace the images within this pull request. Since all the failures are in a single test module, I would run that one module with
the new versions of the images should then appear in To check it worked, you can run the test module again and this time the tests should pass. |
This pull requests regenerates the failing images for tests. The regenerated images either have a non-varying widths or non-varying colors.
https://github.com/matplotlib/matplotlib/blob/main/tools/triage_tests.py is also very helpful as it will show you the images and has an "accept" button that does the copying for you. |
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.
These outputs are unambiguously better.
I am 50/50 on if this should get a behavior change note in case it catches out any downstream libraries that are using this method and will need to update their tests accordingly.
@rcomer, thank you for the detailed directions. @tacaswell, I would agree on adding a behavior change note. As you say, it would avoid headache to those who use tests. Additionally, since we are dealing with #24946, I would like to ask that is it sensible to add an argument to streamplot that allows changing the cap style? Without enforcing a change on streamplot users unlike #25078; this would allow people to produce visually gapless plots if they wish to use round cap styles. |
Giving the code a very quick skim, I think a better extension would be to make it possible to pass any line stlye keywords through (not just cap). We probably should follow the pattern of adding an option like https://github.com/matplotlib/matplotlib/tree/main/doc/api/next_api_changes/behavior <- the behavior change note should go there, please see the 00001-ABC.rst for a template. |
Congratulations on your first PR merged into Matplotlib @gokberkgunes! We hope to hear from you again. |
PR Summary
Streamplot segments stream lines into small pieces of lines in order to have different width and colors from each other. However, by doing the segmentation the connection of lines are getting lost. The loss of connection introduces visible gaps. This commit avoids unnecessary segmentation of a streamline into smaller lines if there is no need to do so. Fixing the problem only for non-varying width and color stream plots.
This commit is based on the comment of @QuLogic.
PR Checklist
Documentation and Tests
pytest
passes)Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
next_whats_new/README.rst
ornext_api_changes/README.rst