Skip to content
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

Add set_XY and set_data to Quiver #22407

Closed
wants to merge 2 commits into from
Closed

Conversation

ianhi
Copy link
Contributor

@ianhi ianhi commented Feb 5, 2022

PR Summary

Will close #22402 and close #11790

still a bit of tidying up to do, and should probably pair with a similar implementation for Barb.

Opening early to get feedback I think I did all the shape setting correctly, but not entirely clear whats happening with all the masking. Also this will enable modifying the number of points and there was originally some concern about that.

Example script:

import matplotlib.pyplot as plt
import numpy as np

X, Y = np.random.rand(10, 2).T
U, V = np.random.rand(10, 2).T

fig, ax = plt.subplots()
Q = ax.quiver(X, Y, U, V)

plt.show(block=False)
plt.pause(2)

X, Y, U, V, C = np.random.rand(11, 5).T
Q.set_data(X, Y, U, V, C)
fig.canvas.draw()
plt.show(block=True)

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@jklymak
Copy link
Member

jklymak commented Feb 5, 2022

The API seems fine, though I wonder about providing the conveniences, versus just set_data. Why does your example need a fig.canvas.draw? (= fig.draw_without_rendering)

@ianhi
Copy link
Contributor Author

ianhi commented Feb 5, 2022

The API seems fine, though I wonder about providing the conveniences, versus just set_data.

I put in both since set_UVC already exists although i suppose instead that could be deprecated?

fig.canvas.draw? (= fig.draw_without_rendering)

I'm a bit confused. the example changes after some time so since it's displayed already you need to call draw to update it

@jklymak
Copy link
Member

jklymak commented Feb 5, 2022

I dont think of fig.canvas.draw as user-facing.

@ianhi
Copy link
Contributor Author

ianhi commented Feb 5, 2022

fig.canvas.draw (or draw_idle) is crucial when doing anything interactive with set_data etc. For example see the slider examples: https://matplotlib.org/stable/gallery/widgets/slider_demo.html or https://matplotlib.org/stable/gallery/animation/strip_chart.html?highlight=codex%20fig%20canvas%20draw here it's necessary to update the figure because the second show doesn't force a draw.

arrows; their locations are fixed when the class is
instantiated. Possibly this method will be useful
in animations.
The only API methods are ``set_UVC()``, ``set_XY``,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove "only"? (Does three count as only?)

Single back-ticks will link, right? I guess one should be consistent with either using () for all or none of the methods.

@oscargus
Copy link
Contributor

Couldn't comment in the source, but Barbs has this in the docs:

The only API method is :meth:`set_UVC`, which can be used to

which no longer is correct.

@oscargus
Copy link
Contributor

oscargus commented Dec 9, 2022

I think this would be nice to get into 3.7. Would you have time to update it?

I guess one can use the docs of the original Quiver class to explain the U, V, and C arguments in set_data.

@ianhi
Copy link
Contributor Author

ianhi commented Dec 9, 2022

I think this would be nice to get into 3.7. Would you have time to update it?

maybe - when is the deadline there? jan 1?

Also dependent on figuring out what I meant by:

still a bit of tidying up to do

also

and should probably pair with a similar implementation for Barb.

probably won't be able to do that

Comment on lines +604 to +605
U, V : ???
C : ???
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to self - this is part of the "cleaning up"

@oscargus
Copy link
Contributor

maybe - when is the deadline there? jan 1?

As I understand it, yes, but with some margins.

@timhoffm
Copy link
Member

and should probably pair with a similar implementation for Barb.

probably won't be able to do that

We can still do that later. Already having this on Quiver is an improvement, and I assume Barb is less often used compared to Quiver.

@jklymak
Copy link
Member

jklymak commented Jan 24, 2023

@ianhi I'll move to Draft until you have time to come back to this...

@jklymak jklymak marked this pull request as draft January 24, 2023 17:23
@ksunden ksunden modified the milestones: v3.8.0, v3.9.0 Aug 8, 2023
@rcomer rcomer mentioned this pull request Oct 11, 2023
3 tasks
@QuLogic
Copy link
Member

QuLogic commented Mar 13, 2024

This was replaced by #26410.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Doc]: Quiver docstring incorrectly claims that only UVC can be set Feature request: set_XY in quiver plots
6 participants