matplotlib.pyplot.barbs#

matplotlib.pyplot.barbs(*args,data=None,**kwargs)[source]#

Plot a 2D field of wind barbs.

Call signature:

barbs([X,Y],U,V,[C],/,**kwargs)

WhereX,Y define the barb locations,U,V define the barbdirections, andC optionally sets the color.

The argumentsX,Y,U,V,C are positional-only and may be1D or 2D.U,V,C may be masked arrays, but maskedX,Yare not supported at present.

Barbs are traditionally used in meteorology as a way to plot the speedand direction of wind observations, but can technically be used toplot any two dimensional vector quantity. As opposed to arrows, whichgive vector magnitude by the length of the arrow, the barbs give morequantitative information about the vector magnitude by putting slantedlines or a triangle for various increments in magnitude, as showschematically below:

:/\    \:/  \    \:/    \    \    \:/      \    \    \:------------------------------

The largest increment is given by a triangle (or "flag"). After thosecome full lines (barbs). The smallest increment is a half line. Thereis only, of course, ever at most 1 half line. If the magnitude issmall and only needs a single half-line and no full lines ortriangles, the half-line is offset from the end of the barb so that itcan be easily distinguished from barbs with a single full line. Themagnitude for the barb shown above would nominally be 65, using thestandard increments of 50, 10, and 5.

See alsohttps://en.wikipedia.org/wiki/Wind_barb.

Parameters:
X, Y1D or 2D array-like, optional

The x and y coordinates of the barb locations. Seepivot for how thebarbs are drawn to the x, y positions.

If not given, they will be generated as a uniform integer meshgrid basedon the dimensions ofU andV.

IfX andY are 1D butU,V are 2D,X,Y are expanded to 2DusingX,Y=np.meshgrid(X,Y). In this caselen(X) andlen(Y)must match the column and row dimensions ofU andV.

U, V1D or 2D array-like

The x and y components of the barb shaft.

C1D or 2D array-like, optional

Numeric data that defines the barb colors by colormapping vianorm andcmap.

This does not support explicit colors. If you want to set colors directly,usebarbcolor instead.

lengthfloat, default: 7

Length of the barb in points; the other parts of the barbare scaled against this.

pivot{'tip', 'middle'} or float, default: 'tip'

The part of the arrow that is anchored to theX,Y grid. The barbrotates about this point. This can also be a number, which shifts thestart of the barb that many points away from grid point.

barbcolorcolor or color sequence

The color of all parts of the barb except for the flags. This parameteris analogous to theedgecolor parameter for polygons, which can be usedinstead. However this parameter will override facecolor.

flagcolorcolor or color sequence

The color of any flags on the barb. This parameter is analogous to thefacecolor parameter for polygons, which can be used instead. However,this parameter will override facecolor. If this is not set (andC hasnot either) thenflagcolor will be set to matchbarbcolor so that thebarb has a uniform color. IfC has been set,flagcolor has no effect.

sizesdict, optional

A dictionary of coefficients specifying the ratio of a givenfeature to the length of the barb. Only those values one wishes tooverride need to be included. These features include:

  • 'spacing' - space between features (flags, full/half barbs)

  • 'height' - height (distance from shaft to top) of a flag or full barb

  • 'width' - width of a flag, twice the width of a full barb

  • 'emptybarb' - radius of the circle used for low magnitudes

fill_emptybool, default: False

Whether the empty barbs (circles) that are drawn should be filled withthe flag color. If they are not filled, the center is transparent.

roundingbool, default: True

Whether the vector magnitude should be rounded when allocating barbcomponents. If True, the magnitude is rounded to the nearest multipleof the half-barb increment. If False, the magnitude is simply truncatedto the next lowest multiple.

barb_incrementsdict, optional

A dictionary of increments specifying values to associate withdifferent parts of the barb. Only those values one wishes tooverride need to be included.

  • 'half' - half barbs (Default is 5)

  • 'full' - full barbs (Default is 10)

  • 'flag' - flags (default is 50)

flip_barbbool or array-like of bool, default: False

Whether the lines and flags should point opposite to normal.Normal behavior is for the barbs and lines to point right (comes from windbarbs having these features point towards low pressure in the NorthernHemisphere).

A single value is applied to all barbs. Individual barbs can be flipped bypassing a bool array of the same size asU andV.

Returns:
barbsBarbs
Other Parameters:
dataindexable object, optional

If given, all parameters also accept a strings, which isinterpreted asdata[s] ifs is a key indata.

**kwargs

The barbs can further be customized usingPolyCollection keywordarguments:

Property

Description

agg_filter

a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image

alpha

array-like or float or None

animated

bool

antialiased oraa orantialiaseds

bool or list of bools

array

array-like or None

capstyle

CapStyle or {'butt', 'projecting', 'round'}

clim

(vmin: float, vmax: float)

clip_box

BboxBase or None

clip_on

bool

clip_path

Patch or (Path, Transform) or None

cmap

Colormap or str or None

color

color or list of RGBA tuples

edgecolor orec oredgecolors

color or list ofcolor or 'face'

facecolor orfacecolors orfc

color or list ofcolor

figure

Figure orSubFigure

gid

str

hatch

{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}

hatch_linewidth

unknown

hatchcolor

color or list ofcolor or 'edge'

in_layout

bool

joinstyle

JoinStyle or {'miter', 'round', 'bevel'}

label

object

linestyle ordashes orlinestyles orls

str or tuple or list thereof

linewidth orlinewidths orlw

float or list of floats

mouseover

bool

norm

Normalize or str or None

offset_transform ortransOffset

Transform

offsets

(N, 2) or (2,) array-like

path_effects

list ofAbstractPathEffect

paths

list of array-like

picker

None or bool or float or callable

pickradius

float

rasterized

bool

sizes

numpy.ndarray or None

sketch_params

(scale: float, length: float, randomness: float)

snap

bool or None

transform

Transform

url

str

urls

list of str or None

verts

list of array-like

verts_and_codes

unknown

visible

bool

zorder

float

Notes

Note

This is thepyplot wrapper foraxes.Axes.barbs.

Examples usingmatplotlib.pyplot.barbs#

Wind barbs

Wind barbs