diff --git a/lib/matplotlib/quiver.py b/lib/matplotlib/quiver.py index f2c7aab2d187..aef58c979c6e 100644 --- a/lib/matplotlib/quiver.py +++ b/lib/matplotlib/quiver.py @@ -228,7 +228,7 @@ class QuiverKey(martist.Artist): """ Labelled arrow for use as a quiver plot scale key.""" halign = {'N': 'center', 'S': 'center', 'E': 'left', 'W': 'right'} valign = {'N': 'bottom', 'S': 'top', 'E': 'center', 'W': 'center'} - pivot = {'N': 'mid', 'S': 'mid', 'E': 'tip', 'W': 'tail'} + pivot = {'N': 'middle', 'S': 'middle', 'E': 'tip', 'W': 'tail'} def __init__(self, Q, X, Y, U, label, **kw): martist.Artist.__init__(self) @@ -708,6 +708,10 @@ def _h_arrows(self, length): X = X - X[:, 3, np.newaxis] # numpy bug? using -= does not # work here unless we multiply # by a float first, as with 'mid'. + elif self.pivot != 'tail': + raise ValueError(("Quiver.pivot must have value in {{'middle', " + "'tip', 'tail'}} not {}").format(self.pivot)) + tooshort = length < self.minlength if tooshort.any(): # Use a heptagonal dot: diff --git a/lib/matplotlib/tests/baseline_images/test_quiver/quiver_key_pivot.png b/lib/matplotlib/tests/baseline_images/test_quiver/quiver_key_pivot.png new file mode 100644 index 000000000000..4763bd26d841 Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_quiver/quiver_key_pivot.png differ diff --git a/lib/matplotlib/tests/test_quiver.py b/lib/matplotlib/tests/test_quiver.py index e95edd47f9ba..21d96aa7d1c0 100644 --- a/lib/matplotlib/tests/test_quiver.py +++ b/lib/matplotlib/tests/test_quiver.py @@ -92,6 +92,22 @@ def test_quiver_copy(): assert q0.V[0] == 2.0 +@image_comparison(baseline_images=['quiver_key_pivot'], + extensions=['png'], remove_text=True) +def test_quiver_key_pivot(): + fig, ax = plt.subplots() + + u, v = np.mgrid[0:2*np.pi:10j, 0:2*np.pi:10j] + + q = ax.quiver(np.sin(u), np.cos(v)) + ax.set_xlim(-2, 11) + ax.set_ylim(-2, 11) + ax.quiverkey(q, 0.5, 1, 1, 'N', labelpos='N') + ax.quiverkey(q, 1, 0.5, 1, 'E', labelpos='E') + ax.quiverkey(q, 0.5, 0, 1, 'S', labelpos='S') + ax.quiverkey(q, 0, 0.5, 1, 'W', labelpos='W') + + if __name__ == '__main__': import nose nose.runmodule()
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: