-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
merge streamplot_demo_features streamplot_demo_masking streamplot_demo_start_points #8155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,56 @@ | |
ax2.streamplot(X, Y, U, V, density=0.6, color='k', linewidth=lw) | ||
|
||
plt.show() | ||
|
||
""" | ||
================================ | ||
Streamplot function with masking | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You'll need to merge this docstring with the one at the beginning to make something coherent. |
||
================================ | ||
|
||
This example shows how streamlines created by the streamplot function skips | ||
masked regions and NaN values. | ||
""" | ||
w = 3 | ||
Y, X = np.mgrid[-w:w:100j, -w:w:100j] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can |
||
U = -1 - X**2 + Y | ||
V = 1 + X - Y**2 | ||
speed = np.sqrt(U*U + V*V) | ||
|
||
mask = np.zeros(U.shape, dtype=bool) | ||
mask[40:60, 40:60] = True | ||
U[:20, :20] = np.nan | ||
U = np.ma.array(U, mask=mask) | ||
|
||
fig, ax = plt.subplots() | ||
ax.streamplot(X, Y, U, V, color='r') | ||
|
||
ax.imshow(~mask, extent=(-w, w, -w, w), alpha=0.5, | ||
interpolation='nearest', cmap=plt.cm.gray) | ||
|
||
plt.show() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove. |
||
|
||
""" | ||
======================================== | ||
Streamplot function with starting points | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, you need to merge this with the first docstring. |
||
======================================== | ||
|
||
This example shows how to fix the streamlines that are plotted, by passing | ||
an array of seed points to the `start_points` keyword argument. | ||
""" | ||
Y, X = np.mgrid[-3:3:100j, -3:3:100j] | ||
U = -1 - X**2 + Y | ||
V = 1 + X - Y**2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can any of these be reused from before? |
||
|
||
# 5 points along the first diagonal and a point in the left upper quadrant | ||
seed_points = np.array([[-2, -1, 0, 1, 2, -1], [-2, -1, 0, 1, 2, 2]]) | ||
|
||
fig, ax = plt.subplots() | ||
strm = ax.streamplot(X, Y, U, V, color=U, linewidth=2, | ||
cmap=plt.cm.autumn, start_points=seed_points.T) | ||
fig.colorbar(strm.lines) | ||
|
||
ax.plot(seed_points[0], seed_points[1], 'bo') | ||
|
||
ax.axis((-3, 3, -3, 3)) | ||
|
||
plt.show() |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove; there's one at the end.