@@ -16,35 +16,21 @@ can now be changed after the collection has been created.
16
16
Y = np.arange(-10, 10, 1)
17
17
U, V = np.meshgrid(X, Y)
18
18
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)
19
21
qc = ax.quiver(X, Y, U, V, C)
20
22
21
23
qc.set_U(U/5)
22
24
23
-
24
- The number of arrows can also be changed.
25
-
26
- .. plot ::
27
- :include-source: true
28
-
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)
25
+ # The number of arrows can also be changed.
39
26
40
27
# Get new X, Y, U, V, C
41
28
X = np.arange(-10, 10, 2)
42
29
Y = np.arange(-10, 10, 2)
43
30
U, V = np.meshgrid(X, Y)
44
31
C = np.hypot(U, V)
32
+ # Use 2D X, Y coordinate (X, Y will not be expanded to 2D)
45
33
X, Y = np.meshgrid(X, Y)
46
- XY = np.column_stack((X.ravel(), Y.ravel()))
47
34
48
35
# Set new values
49
- qc.set_offsets(XY)
50
- qc.set_UVC(U, V, C)
36
+ qc.set_XYUVC(X, Y, U, V, C)
0 commit comments