8000 Add `set_XYUVC` method to be used for all quiver setter · matplotlib/matplotlib@b51a01c · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b51a01c

Browse files
committed
Add set_XYUVC method to be used for all quiver setter
1 parent 92848b2 commit b51a01c

File tree

4 files changed

+274
-105
lines changed

4 files changed

+274
-105
lines changed

doc/users/next_whats_new/add_Quiver_setters.rst

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ can now be changed after the collection has been created.
1616
Y = np.arange(-10, 10, 1)
1717
U, V = np.meshgrid(X, Y)
1818
C = np.hypot(U, V)
19+
# When X and Y are 1D and U, V are 2D, X, Y are expanded to 2D
20+
# using X, Y = np.meshgrid(X, Y)
1921
qc = ax.quiver(X, Y, U, V, C)
2022

2123
qc.set_U(U/5)
@@ -26,25 +28,13 @@ The number of arrows can also be changed.
2628
.. plot::
2729
:include-source: true
2830

29-
import matplotlib.pyplot as plt
30-
from matplotlib.quiver import Quiver
31-
import numpy as np
32-
33-
fig, ax = plt.subplots()
34-
X = np.arange(-10, 10, 1)
35-
Y = np.arange(-10, 10, 1)
36-
U, V = np.meshgrid(X, Y)
37-
C = np.hypot(U, V)
38-
qc = ax.quiver(X, Y, U, V, C)
39-
4031
# Get new X, Y, U, V, C
4132
X = np.arange(-10, 10, 2)
4233
Y = np.arange(-10, 10, 2)
4334
U, V = np.meshgrid(X, Y)
4435
C = np.hypot(U, V)
36+
# Use 2D X, Y coordinate (X, Y will not be expanded to 2D)
4537
X, Y = np.meshgrid(X, Y)
46-
XY = np.column_stack((X.ravel(), Y.ravel()))
4738

4839
# Set new values
49-
qc.set_offsets(XY)
50-
qc.set_UVC(U, V, C)
40+
qc.set_XYUVC(X, Y, U, V, C)

0 commit comments

Comments
 (0)
0