|
3 | 3 | Streamplot
|
4 | 4 | ==========
|
5 | 5 |
|
6 |
| -A stream plot, or stream line plot, is used to display 2D vector fields. This |
7 |
| -example shows a few features of the stream plot function: |
| 6 | +A stream plot, or streamline plot, is used to display 2D vector fields. This |
| 7 | +example shows a few features of the streamplot function: |
8 | 8 |
|
9 |
| - * Varying the color along a stream line. |
10 |
| - * Varying the density of stream lines. |
11 |
| - * Varying the line width along a stream line. |
12 |
| - * Controlling the starting points of stream lines. |
13 |
| - * Stream lines skipping masked regions and NaN values. |
| 9 | + * Varying the color along a streamline. |
| 10 | + * Varying the density of streamlines. |
| 11 | + * Varying the line width along a streamline. |
| 12 | + * Controlling the starting points of streamlines. |
| 13 | + * Streamlines skipping masked regions and NaN values. |
14 | 14 | """
|
15 | 15 | import numpy as np
|
16 | 16 | import matplotlib.pyplot as plt
|
|
34 | 34 | ax1 = fig.add_subplot(gs[0, 1])
|
35 | 35 | strm = ax1.streamplot(X, Y, U, V, color=U, linewidth=2, cmap='autumn')
|
36 | 36 | fig.colorbar(strm.lines)
|
37 |
| -ax1.set_title('Varying color') |
| 37 | +ax1.set_title('Varying Color') |
38 | 38 |
|
39 | 39 | # Varying line width along a streamline
|
40 | 40 | ax2 = fig.add_subplot(gs[1, 0])
|
|
43 | 43 | ax2.set_title('Varying Line Width')
|
44 | 44 |
|
45 | 45 | # Controlling the starting points of the streamlines
|
46 |
| -X, Y = (np.linspace(-3, 3, 100), |
47 |
| - np.linspace(-3, 3, 100)) |
48 |
| -U, V = np.mgrid[-3:3:100j, 0:0:100j] |
49 | 46 | seed_points = np.array([[-2, -1, 0, 1, 2, -1], [-2, -1, 0, 1, 2, 2]])
|
50 | 47 |
|
51 | 48 | ax3 = fig.add_subplot(gs[1, 1])
|
|
59 | 56 | ax3.axis((-w, w, -w, w))
|
60 | 57 |
|
61 | 58 | # Create a mask
|
62 |
| -w = 3 |
63 |
| -Y, X = np.mgrid[-w:w:100j, -w:w:100j] |
64 |
| -U = -1 - X**2 + Y |
65 |
| -V = 1 + X - Y**2 |
66 |
| -speed = np.sqrt(U*U + V*V) |
67 |
| - |
68 | 59 | mask = np.zeros(U.shape, dtype=bool)
|
69 | 60 | mask[40:60, 40:60] = True
|
70 | 61 | U[:20, :20] = np.nan
|
|
0 commit comments