Thanks to visit codestin.com
Credit goes to github.com

Skip to content

quiver: always recalculate in draw(); improve docstring; closes #3709, #3817 [backport to 1.4.x] #4034

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 1 commit into from
Jan 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions lib/matplotlib/quiver.py
Original file line number Diff line number Diff line change
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
Loading
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
Original file line number Diff line number Diff line change
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()