Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 83fb72b

Browse filesBrowse files
tacaswellMeeseeksDev[bot]
authored andcommitted
Backport PR matplotlib#14256: Improve docstring of Axes.barbs
1 parent d76fbc5 commit 83fb72b
Copy full SHA for 83fb72b

File tree

Expand file treeCollapse file tree

1 file changed

+95
-96
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+95
-96
lines changed

‎lib/matplotlib/quiver.py

Copy file name to clipboardExpand all lines: lib/matplotlib/quiver.py
+95-96Lines changed: 95 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -777,142 +777,141 @@ def _h_arrows(self, length):
777777

778778

779779
_barbs_doc = r"""
780-
Plot a 2-D field of barbs.
780+
Plot a 2D field of barbs.
781781
782-
Call signatures::
782+
Call signature::
783783
784-
barb(U, V, **kw)
785-
barb(U, V, C, **kw)
786-
barb(X, Y, U, V, **kw)
787-
barb(X, Y, U, V, C, **kw)
784+
barbs([X, Y], U, V, [C], **kw)
788785
789-
Arguments:
786+
Where *X*, *Y* define the barb locations, *U*, *V* define the barb
787+
directions, and *C* optionally sets the color.
790788
791-
*X*, *Y*:
792-
The x and y coordinates of the barb locations
793-
(default is head of barb; see *pivot* kwarg)
789+
All arguments may be 1D or 2D. *U*, *V*, *C* may be masked arrays, but masked
790+
*X*, *Y* are not supported at present.
794791
795-
*U*, *V*:
796-
Give the x and y components of the barb shaft
792+
Barbs are traditionally used in meteorology as a way to plot the speed
793+
and direction of wind observations, but can technically be used to
794+
plot any two dimensional vector quantity. As opposed to arrows, which
795+
give vector magnitude by the length of the arrow, the barbs give more
796+
quantitative information about the vector magnitude by putting slanted
797+
lines or a triangle for various increments in magnitude, as show
798+
schematically below::
797799
798-
*C*:
799-
An optional array used to map colors to the barbs
800+
: /\ \
801+
: / \ \
802+
: / \ \ \
803+
: / \ \ \
804+
: ------------------------------
800805
801-
All arguments may be 1-D or 2-D arrays or sequences. If *X* and *Y*
802-
are absent, they will be generated as a uniform grid. If *U* and *V*
803-
are 2-D arrays but *X* and *Y* are 1-D, and if ``len(X)`` and ``len(Y)``
804-
match the column and row dimensions of *U*, then *X* and *Y* will be
805-
expanded with :func:`numpy.meshgrid`.
806806
807-
*U*, *V*, *C* may be masked arrays, but masked *X*, *Y* are not
808-
supported at present.
807+
The largest increment is given by a triangle (or "flag"). After those
808+
come full lines (barbs). The smallest increment is a half line. There
809+
is only, of course, ever at most 1 half line. If the magnitude is
810+
small and only needs a single half-line and no full lines or
811+
triangles, the half-line is offset from the end of the barb so that it
812+
can be easily distinguished from barbs with a single full line. The
813+
magnitude for the barb shown above would nominally be 65, using the
814+
standard increments of 50, 10, and 5.
809815
810-
Keyword arguments:
816+
See also https://en.wikipedia.org/wiki/Wind_barb.
817+
818+
819+
820+
Parameters
821+
----------
822+
X, Y : 1D or 2D array-like, optional
823+
The x and y coordinates of the barb locations. See *pivot* for how the
824+
barbs are drawn to the x, y positions.
825+
826+
If not given, they will be generated as a uniform integer meshgrid based
827+
on the dimensions of *U* and *V*.
828+
829+
If *X* and *Y* are 1D but *U*, *V* are 2D, *X*, *Y* are expanded to 2D
830+
using ``X, Y = np.meshgrid(X, Y)``. In this case ``len(X)`` and ``len(Y)``
831+
must match the column and row dimensions of *U* and *V*.
811832
812-
*length*:
833+
U, V : 1D or 2D array-like
834+
The x and y components of the barb shaft.
835+
836+
C : 1D or 2D array-like, optional
837+
Numeric data that defines the barb colors by colormapping via *norm* and
838+
*cmap*.
839+
840+
This does not support explicit colors. If you want to set colors directly,
841+
use *barbcolor* instead.
842+
843+
length : float, default: 7
813844
Length of the barb in points; the other parts of the barb
814845
are scaled against this.
815-
Default is 7.
816846
817-
*pivot*: [ 'tip' | 'middle' | float ]
818-
The part of the arrow that is at the grid point; the arrow rotates
819-
about this point, hence the name *pivot*. Default is 'tip'. Can
820-
also be a number, which shifts the start of the barb that many
821-
points from the origin.
847+
pivot : {'tip', 'middle'} or float, default: 'tip'
848+
The part of the arrow that is anchored to the *X*, *Y* grid. The barb
849+
rotates about this point. This can also be a number, which shifts the
850+
start of the barb that many points away from grid point.
822851
823-
*barbcolor*: [ color | color sequence ]
824-
Specifies the color all parts of the barb except any flags. This
852+
barbcolor : color or color sequence
853+
Specifies the color of all parts of the barb except for the flags. This
825854
parameter is analogous to the *edgecolor* parameter for polygons,
826855
which can be used instead. However this parameter will override
827856
facecolor.
828857
829-
*flagcolor*: [ color | color sequence ]
858+
flagcolor : color or color sequence
830859
Specifies the color of any flags on the barb. This parameter is
831860
analogous to the *facecolor* parameter for polygons, which can be
832-
used instead. However this parameter will override facecolor. If
861+
used instead. However, this parameter will override facecolor. If
833862
this is not set (and *C* has not either) then *flagcolor* will be
834863
set to match *barbcolor* so that the barb has a uniform color. If
835864
*C* has been set, *flagcolor* has no effect.
836865
837-
*sizes*:
866+
sizes : dict, optional
838867
A dictionary of coefficients specifying the ratio of a given
839868
feature to the length of the barb. Only those values one wishes to
840869
override need to be included. These features include:
841870
842-
- 'spacing' - space between features (flags, full/half barbs)
843-
844-
- 'height' - height (distance from shaft to top) of a flag or
845-
full barb
871+
- 'spacing' - space between features (flags, full/half barbs)
872+
- 'height' - height (distance from shaft to top) of a flag or full barb
873+
- 'width' - width of a flag, twice the width of a full barb
874+
- 'emptybarb' - radius of the circle used for low magnitudes
846875
847-
- 'width' - width of a flag, twice the width of a full barb
876+
fill_empty : bool, default: False
877+
Whether the empty barbs (circles) that are drawn should be filled with
878+
the flag color. If they are not filled, the center is transparent.
848879
849-
- 'emptybarb' - radius of the circle used for low magnitudes
880+
rounding : bool, default: True
881+
Whether the vector magnitude should be rounded when allocating barb
882+
components. If True, the magnitude is rounded to the nearest multiple
883+
of the half-barb increment. If False, the magnitude is simply truncated
884+
to the next lowest multiple.
850885
851-
*fill_empty*:
852-
A flag on whether the empty barbs (circles) that are drawn should
853-
be filled with the flag color. If they are not filled, they will
854-
be drawn such that no color is applied to the center. Default is
855-
False
856-
857-
*rounding*:
858-
A flag to indicate whether the vector magnitude should be rounded
859-
when allocating barb components. If True, the magnitude is
860-
rounded to the nearest multiple of the half-barb increment. If
861-
False, the magnitude is simply truncated to the next lowest
862-
multiple. Default is True
863-
864-
*barb_increments*:
886+
barb_increments : dict, optional
865887
A dictionary of increments specifying values to associate with
866888
different parts of the barb. Only those values one wishes to
867889
override need to be included.
868890
869-
- 'half' - half barbs (Default is 5)
870-
871-
- 'full' - full barbs (Default is 10)
872-
873-
- 'flag' - flags (default is 50)
874-
875-
*flip_barb*:
876-
Either a single boolean flag or an array of booleans. Single
877-
boolean indicates whether the lines and flags should point
878-
opposite to normal for all barbs. An array (which should be the
879-
same size as the other data arrays) indicates whether to flip for
880-
each individual barb. Normal behavior is for the barbs and lines
881-
to point right (comes from wind barbs having these features point
882-
towards low pressure in the Northern Hemisphere.) Default is
883-
False
884-
885-
Barbs are traditionally used in meteorology as a way to plot the speed
886-
and direction of wind observations, but can technically be used to
887-
plot any two dimensional vector quantity. As opposed to arrows, which
888-
give vector magnitude by the length of the arrow, the barbs give more
889-
quantitative information about the vector magnitude by putting slanted
890-
lines or a triangle for various increments in magnitude, as show
891-
schematically below::
891+
- 'half' - half barbs (Default is 5)
892+
- 'full' - full barbs (Default is 10)
893+
- 'flag' - flags (default is 50)
892894
893-
: /\ \\
894-
: / \ \\
895-
: / \ \ \\
896-
: / \ \ \\
897-
: ------------------------------
895+
flip_barb : bool or array-like of bool, default: False
896+
Whether the lines and flags should point opposite to normal.
897+
Normal behavior is for the barbs and lines to point right (comes from wind
898+
barbs having these features point towards low pressure in the Northern
899+
Hemisphere).
898900
899-
.. note the double \\ at the end of each line to make the figure
900-
.. render correctly
901+
A single value is applied to all barbs. Individual barbs can be flipped by
902+
passing a bool array of the same size as *U* and *V*.
901903
902-
The largest increment is given by a triangle (or "flag"). After those
903-
come full lines (barbs). The smallest increment is a half line. There
904-
is only, of course, ever at most 1 half line. If the magnitude is
905-
small and only needs a single half-line and no full lines or
906-
triangles, the half-line is offset from the end of the barb so that it
907-
can be easily distinguished from barbs with a single full line. The
908-
magnitude for the barb shown above would nominally be 65, using the
909-
standard increments of 50, 10, and 5.
904+
Returns
905+
-------
906+
barbs : `~matplotlib.quiver.Barbs`
910907
911-
linewidths and edgecolors can be used to customize the barb.
912-
Additional :class:`~matplotlib.collections.PolyCollection` keyword
913-
arguments:
908+
Other Parameters
909+
----------------
910+
**kwargs
911+
The barbs can further be customized using `.PolyCollection` keyword
912+
arguments:
914913
915-
%(PolyCollection)s
914+
%(PolyCollection)s
916915
""" % docstring.interpd.params
917916

918917
docstring.interpd.update(barbs_doc=_barbs_doc)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.