Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 99ad89d commit 9372533Copy full SHA for 9372533
3 files changed
lib/matplotlib/quiver.py
@@ -228,7 +228,7 @@ class QuiverKey(martist.Artist):
228
""" Labelled arrow for use as a quiver plot scale key."""
229
halign = {'N': 'center', 'S': 'center', 'E': 'left', 'W': 'right'}
230
valign = {'N': 'bottom', 'S': 'top', 'E': 'center', 'W': 'center'}
231
- pivot = {'N': 'mid', 'S': 'mid', 'E': 'tip', 'W': 'tail'}
+ pivot = {'N': 'middle', 'S': 'middle', 'E': 'tip', 'W': 'tail'}
232
233
def __init__(self, Q, X, Y, U, label, **kw):
234
martist.Artist.__init__(self)
@@ -708,6 +708,10 @@ def _h_arrows(self, length):
708
X = X - X[:, 3, np.newaxis] # numpy bug? using -= does not
709
# work here unless we multiply
710
# 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
+
715
tooshort = length < self.minlength
716
if tooshort.any():
717
# Use a heptagonal dot:
lib/matplotlib/tests/baseline_images/test_quiver/quiver_key_pivot.png
58.4 KB
lib/matplotlib/tests/test_quiver.py
@@ -92,6 +92,22 @@ def test_quiver_copy():
92
assert q0.V[0] == 2.0
93
94
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
111
if __name__ == '__main__':
112
import nose
113
nose.runmodule()
0 commit comments