Skip to content

Commit

Permalink
quiver: always recalculate when drawing; improve docstring; closes ma…
Browse files Browse the repository at this point in the history
…tplotlib#3709, matplotlib#3817

The reason why the unconditional recalculation now seems to be
needed, but was not in v1.4.0, is unknown.
  • Loading branch information
efiring committed Jan 24, 2015
1 parent 41efb46 commit 6260c48
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/matplotlib/quiver.py
Expand Up @@ -87,12 +87,15 @@
*angles*: [ 'uv' | 'xy' | array ]
With the default 'uv', the arrow aspect ratio is 1, so that
if *U*==*V* the angle of the arrow on the plot is 45 degrees
CCW from the *x*-axis.
With the default 'uv', the arrow axis aspect ratio is 1, so that
if *U*==*V* the orientation of the arrow on the plot is 45 degrees
CCW from the horizontal axis (positive to the right).
With 'xy', the arrow points from (x,y) to (x+u, y+v).
Use this for plotting a gradient field, for example.
Alternatively, arbitrary angles may be specified as an array
of values in degrees, CCW from the *x*-axis.
of values in degrees, CCW from the horizontal axis.
Note: inverting a data axis will correspondingly invert the
arrows *only* with `angles='xy'`.
*scale*: [ *None* | float ]
Data units per arrow length unit, e.g., m/s per plot width; a smaller
Expand Down Expand Up @@ -520,11 +523,9 @@ def get_datalim(self, transData):
@allow_rasterization
def draw(self, renderer):
self._init()
if (self._new_UV or self.angles == 'xy'
or self.scale_units in ['x', 'y', 'xy']):
verts = self._make_verts(self.U, self.V)
self.set_verts(verts, closed=False)
self._new_UV = False
verts = self._make_verts(self.U, self.V)
self.set_verts(verts, closed=False)
self._new_UV = False
mcollections.PolyCollection.draw(self, renderer)

def set_UVC(self, U, V, C=None):
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions lib/matplotlib/tests/test_quiver.py
Expand Up @@ -74,6 +74,15 @@ def test_quiver_with_key():
'size': 'large'})


@image_comparison(baseline_images=['quiver_single_test_image'],
extensions=['png'], remove_text=True)
def test_quiver_single():
fig, ax = plt.subplots()
ax.margins(0.1)

ax.quiver([1], [1], [2], [2])


if __name__ == '__main__':
import nose
nose.runmodule()

0 comments on commit 6260c48

Please sign in to comment.