Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Clean up quiver docstring + add simple quiver example #7913

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

Merged
merged 11 commits into from
Jan 29, 2017
Prev Previous commit
Next Next commit
Remove old simple quiver demo
  • Loading branch information
dstansby committed Jan 23, 2017
commit a63fd7faf6f3b73d46ecc04e43c03393587d93c9
22 changes: 2 additions & 20 deletions 22 examples/pylab_examples/quiver_demo.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
'''
Demonstration of quiver and quiverkey functions. This is using the
new version coming from the code in quiver.py.
Demonstration of advanced quiver and quiverkey functions.

Known problem: the plot autoscaling does not take into account
the arrows, so those on the boundaries are often out of the picture.
This is *not* an easy problem to solve in a perfectly general way.
The workaround is to manually expand the axes.

'''
import matplotlib.pyplot as plt
import numpy as np
Expand All @@ -16,18 +14,6 @@
U = np.cos(X)
V = np.sin(Y)

# 1
plt.figure()
Q = plt.quiver(U, V)
qk = plt.quiverkey(Q, 0.5, 0.98, 2, r'$2 \frac{m}{s}$', labelpos='W',
fontproperties={'weight': 'bold'})
l, r, b, t = plt.axis()
dx, dy = r - l, t - b
plt.axis([l - 0.05*dx, r + 0.05*dx, b - 0.05*dy, t + 0.05*dy])

plt.title('Minimal arguments, no kwargs')

# 2
plt.figure()
Q = plt.quiver(X, Y, U, V, units='width')
qk = plt.quiverkey(Q, 0.9, 0.95, 2, r'$2 \frac{m}{s}$',
Expand All @@ -37,7 +23,6 @@
plt.axis([-1, 7, -1, 7])
plt.title('scales with plot width, not view')
Copy link
Member

Choose a reason for hiding this comment

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

can these be at the top of the plot code? I tend to scan for the title code and then expect the rest of the code underneath it to make the new figure.


# 3
plt.figure()
Q = plt.quiver(X[::3, ::3], Y[::3, ::3], U[::3, ::3], V[::3, ::3],
pivot='mid', color='r', units='inches')
Expand All @@ -47,7 +32,6 @@
plt.axis([-1, 7, -1, 7])
plt.title("pivot='mid'; every third arrow; units='inches'")

# 4
plt.figure()
M = np.hypot(U, V)
Q = plt.quiver(X, Y, U, V, M,
Expand All @@ -62,7 +46,6 @@
plt.axis([-1, 7, -1, 7])
plt.title("scales with x view; pivot='tip'")

# 5
plt.figure()
Q = plt.quiver(X[::3, ::3], Y[::3, ::3], U[::3, ::3], V[::3, ::3],
color='r', units='x',
Expand All @@ -72,7 +55,6 @@
plt.axis([-1, 7, -1, 7])
plt.title("triangular head; scale with x view; black edges")

# 6
plt.figure()
Copy link
Member

Choose a reason for hiding this comment

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

agree with @NelleV that there are a lot of examples here; it's kinda overwhelming and is there a reasonable way for it to be pared down? Specially since this is a pylab example and so all these features are (or should be) documented the OO way?

M = np.zeros(U.shape, dtype='bool')
XMaskStart = U.shape[0]//3
Expand All @@ -85,7 +67,7 @@
U = ma.masked_array(U, mask=M)
V = ma.masked_array(V, mask=M)
Q = plt.quiver(U, V)
qk = plt.quiverkey(Q, 0.5, 0.98, 2, r'$2 \frac{m}{s}$', labelpos='W',
qk = plt.quiverkey(Q, 0.5, 0.96, 2, r'$2 \frac{m}{s}$', labelpos='W',
fontproperties={'weight': 'bold'})
l, r, b, t = plt.axis()
dx, dy = r - l, t - b
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.