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

Skip to content

Commit 6c70996

Browse files
jklymakMeeseeksDev[bot]
authored and
MeeseeksDev[bot]
committed
Backport PR #14135: Improve docs on Axes quiver
1 parent cd8b27a commit 6c70996

File tree

1 file changed

+91
-68
lines changed

1 file changed

+91
-68
lines changed

lib/matplotlib/quiver.py

Lines changed: 91 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,21 @@
2929

3030

3131
_quiver_doc = """
32-
Plot a 2-D field of arrows.
32+
Plot a 2D field of arrows.
3333
34-
Call signatures::
34+
Call signature::
3535
36-
quiver(U, V, **kw)
37-
quiver(U, V, C, **kw)
38-
quiver(X, Y, U, V, **kw)
39-
quiver(X, Y, U, V, C, **kw)
36+
quiver([X, Y], U, V, [C], **kw)
4037
41-
*U* and *V* are the arrow data, *X* and *Y* set the location of the
42-
arrows, and *C* sets the color of the arrows. These arguments may be 1-D or
43-
2-D arrays or sequences.
38+
Where *X*, *Y* define the arrow locations, *U*, *V* define the arrow
39+
directions, and *C* optionally sets the color.
4440
45-
If *X* and *Y* are absent, they will be generated as a uniform grid.
46-
If *U* and *V* are 2-D arrays and *X* and *Y* are 1-D, and if ``len(X)`` and
47-
``len(Y)`` match the column and row dimensions of *U*, then *X* and *Y* will be
48-
expanded with :func:`numpy.meshgrid`.
41+
**Arrow size**
4942
5043
The default settings auto-scales the length of the arrows to a reasonable size.
51-
To change this behavior see the *scale* and *scale_units* kwargs.
44+
To change this behavior see the *scale* and *scale_units* parameters.
45+
46+
**Arrow shape**
5247
5348
The defaults give a slightly swept-back arrow; to make the head a
5449
triangle, make *headaxislength* the same as *headlength*. To make the
@@ -57,110 +52,138 @@
5752
scale down all the head parameters. You will probably do best to leave
5853
minshaft alone.
5954
55+
**Arrow outline**
56+
6057
*linewidths* and *edgecolors* can be used to customize the arrow
6158
outlines.
6259
6360
Parameters
6461
----------
65-
X : 1D or 2D array, sequence, optional
66-
The x coordinates of the arrow locations
67-
Y : 1D or 2D array, sequence, optional
68-
The y coordinates of the arrow locations
69-
U : 1D or 2D array or masked array, sequence
70-
The x components of the arrow vectors
71-
V : 1D or 2D array or masked array, sequence
72-
The y components of the arrow vectors
73-
C : 1D or 2D array, sequence, optional
74-
The arrow colors
75-
units : [ 'width' | 'height' | 'dots' | 'inches' | 'x' | 'y' | 'xy' ]
62+
X, Y : 1D or 2D array-like, optional
63+
The x and y coordinates of the arrow locations.
64+
65+
If not given, they will be generated as a uniform integer meshgrid based
66+
on the dimensions of *U* and *V*.
67+
68+
If *X* and *Y* are 1D but *U*, *V* are 2D, *X*, *Y* are expanded to 2D
69+
using ``X, Y = np.meshgrid(X, Y)``. In this case ``len(X)`` and ``len(Y)``
70+
must match the column and row dimensions of *U* and *V*.
71+
72+
U, V : 1D or 2D array-like
73+
The x and y direction components of the arrow vectors.
74+
75+
C : 1D or 2D array-like, optional
76+
Numeric data that defines the arrow colors by colormapping via *norm* and
77+
*cmap*.
78+
79+
This does not support explicit colors. If you want to set colors directly,
80+
use *color* instead.
81+
82+
units : {'width', 'height', 'dots', 'inches', 'x', 'y' 'xy'}, default: 'width'
7683
The arrow dimensions (except for *length*) are measured in multiples of
7784
this unit.
7885
79-
'width' or 'height': the width or height of the axis
80-
81-
'dots' or 'inches': pixels or inches, based on the figure dpi
86+
The following values are supported:
8287
83-
'x', 'y', or 'xy': respectively *X*, *Y*, or :math:`\\sqrt{X^2 + Y^2}`
84-
in data units
88+
- 'width', 'height': The width or height of the axis.
89+
- 'dots', 'inches': Pixels or inches based on the figure dpi.
90+
- 'x', 'y', 'xy': *X*, *Y* or :math:`\\sqrt{X^2 + Y^2}` in data units.
8591
8692
The arrows scale differently depending on the units. For
8793
'x' or 'y', the arrows get larger as one zooms in; for other
8894
units, the arrow size is independent of the zoom state. For
8995
'width or 'height', the arrow size increases with the width and
9096
height of the axes, respectively, when the window is resized;
9197
for 'dots' or 'inches', resizing does not change the arrows.
92-
angles : [ 'uv' | 'xy' ], array, optional
93-
Method for determining the angle of the arrows. Default is 'uv'.
9498
95-
'uv': the arrow axis aspect ratio is 1 so that
96-
if *U*==*V* the orientation of the arrow on the plot is 45 degrees
97-
counter-clockwise from the horizontal axis (positive to the right).
99+
angles : {'uv', 'xy'} or array-like, optional, default: 'uv'
100+
Method for determining the angle of the arrows.
101+
102+
- 'uv': The arrow axis aspect ratio is 1 so that
103+
if *U* == *V* the orientation of the arrow on the plot is 45 degrees
104+
counter-clockwise from the horizontal axis (positive to the right).
105+
106+
Use this if the arrows symbolize a quantity that is not based on
107+
*X*, *Y* data coordinates.
108+
109+
- 'xy': Arrows point from (x,y) to (x+u, y+v).
110+
Use this for plotting a gradient field, for example.
98111
99-
'xy': arrows point from (x,y) to (x+u, y+v).
100-
Use this for plotting a gradient field, for example.
112+
- Alternatively, arbitrary angles may be specified explicitly as an array
113+
of values in degrees, counter-clockwise from the horizontal axis.
101114
102-
Alternatively, arbitrary angles may be specified as an array
103-
of values in degrees, counter-clockwise from the horizontal axis.
115+
In this case *U*, *V* is only used to determine the length of the
116+
arrows.
104117
105118
Note: inverting a data axis will correspondingly invert the
106119
arrows only with ``angles='xy'``.
107-
scale : None, float, optional
120+
121+
scale : float, optional
108122
Number of data units per arrow length unit, e.g., m/s per plot width; a
109123
smaller scale parameter makes the arrow longer. Default is *None*.
110124
111125
If *None*, a simple autoscaling algorithm is used, based on the average
112126
vector length and the number of vectors. The arrow length unit is given by
113-
the *scale_units* parameter
114-
scale_units : [ 'width' | 'height' | 'dots' | 'inches' | 'x' | 'y' | 'xy' ], \
115-
None, optional
127+
the *scale_units* parameter.
128+
129+
scale_units : {'width', 'height', 'dots', 'inches', 'x', 'y', 'xy'}, optional
116130
If the *scale* kwarg is *None*, the arrow length unit. Default is *None*.
117131
118132
e.g. *scale_units* is 'inches', *scale* is 2.0, and
119133
``(u,v) = (1,0)``, then the vector will be 0.5 inches long.
120134
121-
If *scale_units* is 'width'/'height', then the vector will be half the
135+
If *scale_units* is 'width' or 'height', then the vector will be half the
122136
width/height of the axes.
123137
124138
If *scale_units* is 'x' then the vector will be 0.5 x-axis
125139
units. To plot vectors in the x-y plane, with u and v having
126140
the same units as x and y, use
127141
``angles='xy', scale_units='xy', scale=1``.
128-
width : scalar, optional
142+
143+
width : float, optional
129144
Shaft width in arrow units; default depends on choice of units,
130145
above, and number of vectors; a typical starting value is about
131146
0.005 times the width of the plot.
132-
headwidth : scalar, optional
133-
Head width as multiple of shaft width, default is 3
134-
headlength : scalar, optional
135-
Head length as multiple of shaft width, default is 5
136-
headaxislength : scalar, optional
137-
Head length at shaft intersection, default is 4.5
138-
minshaft : scalar, optional
147+
148+
headwidth : float, optional, default: 3
149+
Head width as multiple of shaft width.
150+
151+
headlength : float, optional, default: 5
152+
Head length as multiple of shaft width.
153+
154+
headaxislength : float, optional, default: 4.5
155+
Head length at shaft intersection.
156+
157+
minshaft : float, optional, default: 1
139158
Length below which arrow scales, in units of head length. Do not
140159
set this to less than 1, or small arrows will look terrible!
141-
Default is 1
142-
minlength : scalar, optional
160+
161+
minlength : float, optional, default: 1
143162
Minimum length as a multiple of shaft width; if an arrow length
144163
is less than this, plot a dot (hexagon) of this diameter instead.
145-
Default is 1.
146-
pivot : [ 'tail' | 'mid' | 'middle' | 'tip' ], optional
147-
The part of the arrow that is at the grid point; the arrow rotates
148-
about this point, hence the name *pivot*.
149-
color : [ color | color sequence ], optional
150-
This is a synonym for the
151-
:class:`~matplotlib.collections.PolyCollection` facecolor kwarg.
152-
If *C* has been set, *color* has no effect.
153164
154-
Notes
155-
-----
156-
Additional :class:`~matplotlib.collections.PolyCollection`
157-
keyword arguments:
165+
pivot : {'tail', 'mid', 'middle', 'tip'}, optional, default: 'tail'
166+
The part of the arrow that is anchored to the *X*, *Y* grid. The arrow
167+
rotates about this point.
158168
159-
%(PolyCollection)s
169+
'mid' is a synonym for 'middle'.
170+
171+
color : color or color sequence, optional
172+
Explicit color(s) for the arrows. If *C* has been set, *color* has no
173+
effect.
174+
175+
This is a synonym for the `~.PolyCollection` *facecolor* parameter.
176+
177+
Other Parameters
178+
----------------
179+
**kwargs : `~matplotlib.collections.PolyCollection` properties, optional
180+
All other keyword arguments are passed on to `.PolyCollection`:
181+
182+
%(PolyCollection)s
160183
161184
See Also
162185
--------
163-
quiverkey : Add a key to a quiver plot
186+
quiverkey : Add a key to a quiver plot.
164187
""" % docstring.interpd.params
165188

166189
_quiverkey_doc = """

0 commit comments

Comments
 (0)