8000 merge streamplot_demo_features streamplot_demo_masking streamplot_demo_start_points by patniharshit · Pull Request #8155 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions examples/images_contours_and_fields/streamplot_demo_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,56 @@
ax2.streamplot(X, Y, U, V, density=0.6, color='k', linewidth=lw)

plt.show()
Copy link
Member

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.


"""
================================
Streamplot function with masking
Copy link
Member

Choose a reason for hiding this comment

The 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]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can X and Y be reused from above?

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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove.


"""
========================================
Streamplot function with starting points
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The 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()
29 changes: 0 additions & 29 deletions examples/images_contours_and_fields/streamplot_demo_masking.py

This file was deleted.

This file was deleted.

0