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

Skip to content

Commit 476e0c2

Browse files
authored
Merge pull request #14256 from timhoffm/doc-barbs
DOC: Improve docstring of Axes.barbs
2 parents c8b9292 + 10baab0 commit 476e0c2

1 file changed

Lines changed: 95 additions & 96 deletions

File tree

lib/matplotlib/quiver.py

Lines changed: 95 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -779,142 +779,141 @@ def _h_arrows(self, length):
779779

780780

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

920919
docstring.interpd.update(barbs_doc=_barbs_doc)

0 commit comments

Comments
 (0)