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

Commit 9372533

Browse filesBrowse files
efiringjenshnielsen
authored andcommitted
Merge pull request #5620 from tacaswell/fix_quiverkey
FIX: quiver key pivot location
1 parent 99ad89d commit 9372533
Copy full SHA for 9372533

File tree

Expand file treeCollapse file tree

3 files changed

+21
-1
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+21
-1
lines changed

‎lib/matplotlib/quiver.py

Copy file name to clipboardExpand all lines: lib/matplotlib/quiver.py
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class QuiverKey(martist.Artist):
228228
""" Labelled arrow for use as a quiver plot scale key."""
229229
halign = {'N': 'center', 'S': 'center', 'E': 'left', 'W': 'right'}
230230
valign = {'N': 'bottom', 'S': 'top', 'E': 'center', 'W': 'center'}
231-
pivot = {'N': 'mid', 'S': 'mid', 'E': 'tip', 'W': 'tail'}
231+
pivot = {'N': 'middle', 'S': 'middle', 'E': 'tip', 'W': 'tail'}
232232

233233
def __init__(self, Q, X, Y, U, label, **kw):
234234
martist.Artist.__init__(self)
@@ -708,6 +708,10 @@ def _h_arrows(self, length):
708708
X = X - X[:, 3, np.newaxis] # numpy bug? using -= does not
709709
# work here unless we multiply
710710
# by a float first, as with 'mid'.
711+
elif self.pivot != 'tail':
712+
raise ValueError(("Quiver.pivot must have value in {{'middle', "
713+
"'tip', 'tail'}} not {}").format(self.pivot))
714+
711715
tooshort = length < self.minlength
712716
if tooshort.any():
713717
# Use a heptagonal dot:
Loading

‎lib/matplotlib/tests/test_quiver.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_quiver.py
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,22 @@ def test_quiver_copy():
9292
assert q0.V[0] == 2.0
9393

9494

95+
@image_comparison(baseline_images=['quiver_key_pivot'],
96+
extensions=['png'], remove_text=True)
97+
def test_quiver_key_pivot():
98+
fig, ax = plt.subplots()
99+
100+
u, v = np.mgrid[0:2*np.pi:10j, 0:2*np.pi:10j]
101+
102+
q = ax.quiver(np.sin(u), np.cos(v))
103+
ax.set_xlim(-2, 11)
104+
ax.set_ylim(-2, 11)
105+
ax.quiverkey(q, 0.5, 1, 1, 'N', labelpos='N')
106+
ax.quiverkey(q, 1, 0.5, 1, 'E', labelpos='E')
107+
ax.quiverkey(q, 0.5, 0, 1, 'S', labelpos='S')
108+
ax.quiverkey(q, 0, 0.5, 1, 'W', labelpos='W')
109+
110+
95111
if __name__ == '__main__':
96112
import nose
97113
nose.runmodule()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.