|
1 | 1 | """ |
2 | | -=========== |
3 | | -barbs(U, V) |
4 | | -=========== |
| 2 | +================ |
| 3 | +barbs(X, Y U, V) |
| 4 | +================ |
5 | 5 |
|
6 | 6 | See `~matplotlib.axes.Axes.barbs`. |
7 | 7 | """ |
8 | 8 | import matplotlib.pyplot as plt |
9 | 9 | import numpy as np |
10 | 10 |
|
11 | | -plt.style.use('_mpl-gallery') |
| 11 | +plt.style.use('_mpl-gallery-nogrid') |
12 | 12 |
|
13 | 13 | # make data: |
14 | | -np.random.seed(1) |
15 | | -X = [[2, 4, 6]] |
16 | | -Y = [[1.5, 3, 2]] |
17 | | -U = np.zeros_like(X) |
18 | | -V = -np.ones_like(X) * np.linspace(50, 100, 3) |
| 14 | +X, Y = np.meshgrid([1, 2, 3, 4], [1, 2, 3, 4]) |
| 15 | +angle = np.pi / 180 * np.array([[15., 30, 35, 45], |
| 16 | + [25., 40, 55, 60], |
| 17 | + [35., 50, 65, 75], |
| 18 | + [45., 60, 75, 90]]) |
| 19 | +amplitude = np.array([[5, 10, 25, 50], |
| 20 | + [10, 15, 30, 60], |
| 21 | + [15, 26, 50, 70], |
| 22 | + [20, 45, 80, 100]]) |
| 23 | +U = amplitude * np.sin(angle) |
| 24 | +V = amplitude * np.cos(angle) |
19 | 25 |
|
20 | 26 | # plot: |
21 | 27 | fig, ax = plt.subplots() |
22 | 28 |
|
23 | | -ax.barbs(X, Y, U, V, barbcolor="C0", flagcolor="C0", length=10, linewidth=1.5) |
| 29 | +ax.barbs(X, Y, U, V, barbcolor="C0", flagcolor="C0", length=7, linewidth=1.5) |
24 | 30 |
|
25 | | -ax.set(xlim=(0, 8), xticks=np.arange(1, 8), |
26 | | - ylim=(0, 8), yticks=np.arange(1, 8)) |
| 31 | +ax.set(xlim=(0, 4.5), ylim=(0, 4.5)) |
27 | 32 |
|
28 | 33 | plt.show() |
0 commit comments