ENH: add support for varying colors in quiver annotations #3822
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.
PR Summary
Improve wrapping around
matplotlib.axes.Axes.quiver
's complicated signature to enable the optional 5th positional argumentC
.I'm also refactoring
QuiverCallback
andCuttingQuiverCallback
to avoid duplicating code as much as possible.A 'bonus' change here is that I'm allowing arbitary keyword arguments to be passed down to the wrapped method, because it's much more intuitive to pass
cmap="inferno"
thanplot_args=dict(cmap="inferno")
. If requested I can remove this from the PR and possibly repurpose it as a new PR, making similar changes to all callbacks that allow it (i.e. the ones that have only one such dictionary argument)Another bonus is that I fixed a small bug with the
normalize
bool flag where users would get a divide-by-zero warning when using normalisation for a field that has 0-len elements.usage
note that this works with matplotlib 2.2 (oldest supported) as well as 3.5 (newest).
see their old doc here https://matplotlib.org/2.2.2/api/_as_gen/matplotlib.axes.Axes.quiver.html?highlight=quiver#matplotlib.axes.Axes.quiver
for completness, introducing this new "field_c" parameter is technically a breaking change for any user code relying on "factor" being usable as a third positional argument. I personally think it's okay, as long as it's explicitly mentioned in the release notes, because it's impossible to mutate the signature continuously without a breaking change. I'm making all arguments keyword-only to remedy this source of problems in the future.