|
15 | 15 | V = np.sin(Y) |
16 | 16 |
|
17 | 17 | plt.figure() |
| 18 | +plt.title('scales with plot width, not view') |
18 | 19 | Q = plt.quiver(X, Y, U, V, units='width') |
19 | 20 | qk = plt.quiverkey(Q, 0.9, 0.95, 2, r'$2 \frac{m}{s}$', |
20 | 21 | labelpos='E', |
21 | 22 | coordinates='figure', |
22 | 23 | fontproperties={'weight': 'bold'}) |
23 | 24 | plt.axis([-1, 7, -1, 7]) |
24 | | -plt.title('scales with plot width, not view') |
25 | 25 |
|
26 | 26 | plt.figure() |
| 27 | +plt.title("pivot='mid'; every third arrow; units='inches'") |
27 | 28 | Q = plt.quiver(X[::3, ::3], Y[::3, ::3], U[::3, ::3], V[::3, ::3], |
28 | 29 | pivot='mid', color='r', units='inches') |
29 | 30 | qk = plt.quiverkey(Q, 0.5, 0.03, 1, r'$1 \frac{m}{s}$', |
30 | 31 | fontproperties={'weight': 'bold'}) |
31 | 32 | plt.plot(X[::3, ::3], Y[::3, ::3], 'k.') |
32 | 33 | plt.axis([-1, 7, -1, 7]) |
33 | | -plt.title("pivot='mid'; every third arrow; units='inches'") |
34 | 34 |
|
35 | 35 | plt.figure() |
| 36 | +plt.title("scales with x view; pivot='tip'") |
36 | 37 | M = np.hypot(U, V) |
37 | 38 | Q = plt.quiver(X, Y, U, V, M, |
38 | 39 | units='x', |
|
44 | 45 | fontproperties={'weight': 'bold'}) |
45 | 46 | plt.plot(X, Y, 'k.', markersize=2) |
46 | 47 | plt.axis([-1, 7, -1, 7]) |
47 | | -plt.title("scales with x view; pivot='tip'") |
48 | 48 |
|
49 | 49 | plt.figure() |
| 50 | +plt.title("triangular head; scale with x view; black edges") |
| 51 | + |
50 | 52 | Q = plt.quiver(X[::3, ::3], Y[::3, ::3], U[::3, ::3], V[::3, ::3], |
51 | 53 | color='r', units='x', |
52 | 54 | linewidths=(0.5,), edgecolors=('k'), headaxislength=5) |
53 | 55 | qk = plt.quiverkey(Q, 0.5, 0.03, 1, r'$1 \frac{m}{s}$', |
54 | 56 | fontproperties={'weight': 'bold'}) |
55 | 57 | plt.axis([-1, 7, -1, 7]) |
56 | | -plt.title("triangular head; scale with x view; black edges") |
57 | 58 |
|
58 | 59 | plt.figure() |
| 60 | +plt.title('Minimal arguments, no kwargs - masked values') |
| 61 | + |
59 | 62 | M = np.zeros(U.shape, dtype='bool') |
60 | | -XMaskStart = U.shape[0]//3 |
61 | | -YMaskStart = U.shape[1]//3 |
62 | | -XMaskStop = 2*U.shape[0]//3 |
63 | | -YMaskStop = 2*U.shape[1]//3 |
| 63 | +XMaskStart = U.shape[0] // 3 |
| 64 | +YMaskStart = U.shape[1] // 3 |
| 65 | +XMaskStop = 2 * U.shape[0] // 3 |
| 66 | +YMaskStop = 2 * U.shape[1] // 3 |
64 | 67 |
|
65 | 68 | M[XMaskStart:XMaskStop, |
66 | 69 | YMaskStart:YMaskStop] = True |
|
72 | 75 | l, r, b, t = plt.axis() |
73 | 76 | dx, dy = r - l, t - b |
74 | 77 | plt.axis([l - 0.05 * dx, r + 0.05 * dx, b - 0.05 * dy, t + 0.05 * dy]) |
75 | | -plt.title('Minimal arguments, no kwargs - masked values') |
76 | | - |
77 | 78 |
|
78 | 79 | plt.show() |
0 commit comments