Skip to content

Commit 6f1293e

Browse files
committed
add docstring for ax.quiver, including a return section
1 parent a510e32 commit 6f1293e

File tree

1 file changed

+167
-0
lines changed

1 file changed

+167
-0
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5089,6 +5089,173 @@ def _quiver_units(self, args, kw):
50895089
# args can by a combination if X, Y, U, V, C and all should be replaced
50905090
@_preprocess_data()
50915091
def quiver(self, *args, **kw):
5092+
"""
5093+
Plot a 2D field of arrows.
5094+
5095+
Call signature::
5096+
5097+
quiver([X, Y], U, V, [C], **kw)
5098+
5099+
*X*, *Y* define the arrow locations, *U*, *V* define the arrow directions, and
5100+
*C* optionally sets the color.
5101+
5102+
**Arrow size**
5103+
5104+
The default settings auto-scales the length of the arrows to a reasonable size.
5105+
To change this behavior see the *scale* and *scale_units* parameters.
5106+
5107+
**Arrow shape**
5108+
5109+
The defaults give a slightly swept-back arrow; to make the head a
5110+
triangle, make *headaxislength* the same as *headlength*. To make the
5111+
arrow more pointed, reduce *headwidth* or increase *headlength* and
5112+
*headaxislength*. To make the head smaller relative to the shaft,
5113+
scale down all the head parameters. You will probably do best to leave
5114+
minshaft alone.
5115+
5116+
**Arrow outline**
5117+
5118+
*linewidths* and *edgecolors* can be used to customize the arrow
5119+
outlines.
5120+
5121+
Parameters
5122+
----------
5123+
X, Y : 1D or 2D array-like, optional
5124+
The x and y coordinates of the arrow locations.
5125+
5126+
If not given, they will be generated as a uniform integer meshgrid based
5127+
on the dimensions of *U* and *V*.
5128+
5129+
If *X* and *Y* are 1D but *U*, *V* are 2D, *X*, *Y* are expanded to 2D
5130+
using ``X, Y = np.meshgrid(X, Y)``. In this case ``len(X)`` and ``len(Y)``
5131+
must match the column and row dimensions of *U* and *V*.
5132+
5133+
U, V : 1D or 2D array-like
5134+
The x and y direction components of the arrow vectors.
5135+
5136+
They must have the same number of elements, matching the number of arrow
5137+
locations. *U* and *V* may be masked. Only locations unmasked in
5138+
*U*, *V*, and *C* will be drawn.
5139+
5140+
C : 1D or 2D array-like, optional
5141+
Numeric data that defines the arrow colors by colormapping via *norm* and
5142+
*cmap*.
5143+
5144+
This does not support explicit colors. If you want to set colors directly,
5145+
use *color* instead. The size of *C* must match the number of arrow
5146+
locations.
5147+
5148+
units : {'width', 'height', 'dots', 'inches', 'x', 'y', 'xy'}, default: 'width'
5149+
The arrow dimensions (except for *length*) are measured in multiples of
5150+
this unit.
5151+
5152+
The following values are supported:
5153+
5154+
- 'width', 'height': The width or height of the axis.
5155+
- 'dots', 'inches': Pixels or inches based on the figure dpi.
5156+
- 'x', 'y', 'xy': *X*, *Y* or :math:`\\sqrt{X^2 + Y^2}` in data units.
5157+
5158+
The arrows scale differently depending on the units. For
5159+
'x' or 'y', the arrows get larger as one zooms in; for other
5160+
units, the arrow size is independent of the zoom state. For
5161+
'width or 'height', the arrow size increases with the width and
5162+
height of the axes, respectively, when the window is resized;
5163+
for 'dots' or 'inches', resizing does not change the arrows.
5164+
5165+
angles : {'uv', 'xy'} or array-like, default: 'uv'
5166+
Method for determining the angle of the arrows.
5167+
5168+
- 'uv': The arrow axis aspect ratio is 1 so that
5169+
if *U* == *V* the orientation of the arrow on the plot is 45 degrees
5170+
counter-clockwise from the horizontal axis (positive to the right).
5171+
5172+
Use this if the arrows symbolize a quantity that is not based on
5173+
*X*, *Y* data coordinates.
5174+
5175+
- 'xy': Arrows point from (x, y) to (x+u, y+v).
5176+
Use this for plotting a gradient field, for example.
5177+
5178+
- Alternatively, arbitrary angles may be specified explicitly as an array
5179+
of values in degrees, counter-clockwise from the horizontal axis.
5180+
5181+
In this case *U*, *V* is only used to determine the length of the
5182+
arrows.
5183+
5184+
Note: inverting a data axis will correspondingly invert the
5185+
arrows only with ``angles='xy'``.
5186+
5187+
scale : float, optional
5188+
Number of data units per arrow length unit, e.g., m/s per plot width; a
5189+
smaller scale parameter makes the arrow longer. Default is *None*.
5190+
5191+
If *None*, a simple autoscaling algorithm is used, based on the average
5192+
vector length and the number of vectors. The arrow length unit is given by
5193+
the *scale_units* parameter.
5194+
5195+
scale_units : {'width', 'height', 'dots', 'inches', 'x', 'y', 'xy'}, optional
5196+
If the *scale* kwarg is *None*, the arrow length unit. Default is *None*.
5197+
5198+
e.g. *scale_units* is 'inches', *scale* is 2.0, and ``(u, v) = (1, 0)``,
5199+
then the vector will be 0.5 inches long.
5200+
5201+
If *scale_units* is 'width' or 'height', then the vector will be half the
5202+
width/height of the axes.
5203+
5204+
If *scale_units* is 'x' then the vector will be 0.5 x-axis
5205+
units. To plot vectors in the x-y plane, with u and v having
5206+
the same units as x and y, use
5207+
``angles='xy', scale_units='xy', scale=1``.
5208+
5209+
width : float, optional
5210+
Shaft width in arrow units; default depends on choice of units,
5211+
above, and number of vectors; a typical starting value is about
5212+
0.005 times the width of the plot.
5213+
5214+
headwidth : float, default: 3
5215+
Head width as multiple of shaft width.
5216+
5217+
headlength : float, default: 5
5218+
Head length as multiple of shaft width.
5219+
5220+
headaxislength : float, default: 4.5
5221+
Head length at shaft intersection.
5222+
5223+
minshaft : float, default: 1
5224+
Length below which arrow scales, in units of head length. Do not
5225+
set this to less than 1, or small arrows will look terrible!
5226+
5227+
minlength : float, default: 1
5228+
Minimum length as a multiple of shaft width; if an arrow length
5229+
is less than this, plot a dot (hexagon) of this diameter instead.
5230+
5231+
pivot : {'tail', 'mid', 'middle', 'tip'}, default: 'tail'
5232+
The part of the arrow that is anchored to the *X*, *Y* grid. The arrow
5233+
rotates about this point.
5234+
5235+
'mid' is a synonym for 'middle'.
5236+
5237+
color : color or color sequence, optional
5238+
Explicit color(s) for the arrows. If *C* has been set, *color* has no
5239+
effect.
5240+
5241+
This is a synonym for the `~.PolyCollection` *facecolor* parameter.
5242+
5243+
Other Parameters
5244+
----------------
5245+
**kwargs : `~matplotlib.collections.PolyCollection` properties, optional
5246+
All other keyword arguments are passed on to `.PolyCollection`:
5247+
5248+
%(PolyCollection_kwdoc)s
5249+
5250+
Returns
5251+
----------------
5252+
The new `matplotlib.quiver.Quiver` object.
5253+
5254+
5255+
See Also
5256+
--------
5257+
.Axes.quiverkey : Add a key to a quiver plot.
5258+
""" % docstring.interpd.params
50925259
# Make sure units are handled for x and y values
50935260
args = self._quiver_units(args, kw)
50945261

0 commit comments

Comments
 (0)