-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add new num_arrows option to streamplot #27617
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
1431c13
to
ab7c486
Compare
ab7c486
to
1c4b082
Compare
Yay, I have written some very hacky code to achieve this! |
|
||
|
||
:include-source: true | ||
:alt: One charts, identified as ax and ax2, showing a streamplot. Each streamline |
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.
:alt: One charts, identified as ax and ax2, showing a streamplot. Each streamline | |
:alt: One charts, identified as ax, showing a streamplot. Each streamline |
I might suggest using |
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.
Tiny language nit.
But I also wonder if this should go on Thursdays call or get cleared by @tacaswell or @timhoffm since it's new API.
|
||
.. plot:: | ||
:include-source: true | ||
:alt: One chart showing a streamplot. Each streamline has a three arrows. |
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.
:alt: One chart showing a streamplot. Each streamline has a three arrows. | |
:alt: One chart showing a streamplot. Each streamline has three arrows. |
Number of arrows per streamline. The arrows are spaced equally along the steps | ||
each streamline takes. Note that this can be different to being spaced equally | ||
along the distance of the streamline. |
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.
It's a little bit unclear to me why this information is important/difference between steps and distance - is there a place where this is discussed?
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.
I put this in because before I worked out why not, it was a surprise to me that the arrows weren't visually equidistant along the streamline. Happy to drop this if it causes more confusion than it clears up, or try and clarify it a bit?
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.
Clarify, but going by your reply I think something like this is what I'm after"
The arrows are spaced equally along the steps each streamline takes, which means they may not be spaced equally along the distance of the streamline."
Where i can just look up the diff between steps and distance
lib/matplotlib/streamplot.py
Outdated
if isinstance(linewidth, np.ndarray): | ||
line_widths = interpgrid(linewidth, tgx, tgy)[:-1] | ||
line_kw['linewidth'].extend(line_widths) |
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.
This can't be right? It'll extend line_kw['linewidth']
for each arrow, but it's passed to the LineCollection
.
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.
I slightly favor |
Dear all, I want to know if this option (num_arrows) is already implemented in streamplot. |
It's not currently implemented - unfortunately I don't have time at the moment to finish this PR, so someone else is welcome to pick it up and address the comments above. |
Fix test image numarrows > narrows
Fix example
Co-authored-by: Kyle Sunden <git@ksunden.space>
e873739
to
721db75
Compare
I've rebased and handled the comments. |
721db75
to
7281b82
Compare
Not sure why the tolerance is necessary, but it doesn't fail everywhere, so I've put it back. |
7281b82
to
0a5c227
Compare
❤️ thanks to everyone that picked this up and pushed it over the line! |
PR summary
This allows more than one arrow to be plotted per streamline. A rebase and tidy up of #17741.
To avoid adding a new test image I modified an existing one - I hope that's okay?
Fixes #17740
PR checklist