|
23 | 23 | V = 1 + X - Y**2
|
24 | 24 | speed = np.sqrt(U**2 + V**2)
|
25 | 25 |
|
26 |
| -fig, axs = plt.subplots(3, 2, figsize=(7, 9), height_ratios=[1, 1, 2]) |
| 26 | +fig, axs = plt.subplots(4, 2, figsize=(7, 12), height_ratios=[1, 1, 1, 2]) |
27 | 27 | axs = axs.flat
|
28 | 28 |
|
29 | 29 | # Varying density along a streamline
|
|
52 | 52 | axs[3].plot(seed_points[0], seed_points[1], 'bo')
|
53 | 53 | axs[3].set(xlim=(-w, w), ylim=(-w, w))
|
54 | 54 |
|
| 55 | +# Adding more than one arrow to each streamline |
| 56 | +axs[4].streamplot(X, Y, U, V, numarrows=3) |
| 57 | +axs[4].set_title('Multiple arrows') |
| 58 | + |
| 59 | +axs[5].axis("off") |
| 60 | + |
55 | 61 | # Create a mask
|
56 | 62 | mask = np.zeros(U.shape, dtype=bool)
|
57 | 63 | mask[40:60, 40:60] = True
|
58 | 64 | U[:20, :20] = np.nan
|
59 | 65 | U = np.ma.array(U, mask=mask)
|
60 | 66 |
|
61 |
| -axs[4].streamplot(X, Y, U, V, color='r') |
62 |
| -axs[4].set_title('Streamplot with Masking') |
| 67 | +axs[6].streamplot(X, Y, U, V, color='r') |
| 68 | +axs[6].set_title('Streamplot with Masking') |
63 | 69 |
|
64 |
| -axs[4].imshow(~mask, extent=(-w, w, -w, w), alpha=0.5, cmap='gray', |
| 70 | +axs[6].imshow(~mask, extent=(-w, w, -w, w), alpha=0.5, cmap='gray', |
65 | 71 | aspect='auto')
|
66 |
| -axs[4].set_aspect('equal') |
| 72 | +axs[6].set_aspect('equal') |
67 | 73 |
|
68 |
| -axs[5].streamplot(X, Y, U, V, broken_streamlines=False) |
69 |
| -axs[5].set_title('Streamplot with unbroken streamlines') |
| 74 | +axs[7].streamplot(X, Y, U, V, broken_streamlines=False) |
| 75 | +axs[7].set_title('Streamplot with unbroken streamlines') |
70 | 76 |
|
71 | 77 | plt.tight_layout()
|
72 | 78 | plt.show()
|
|
0 commit comments