matplotlib.axes.Axes.errorbar#

Axes.errorbar(x,y,yerr=None,xerr=None,fmt='',*,ecolor=None,elinewidth=None,capsize=None,barsabove=False,lolims=False,uplims=False,xlolims=False,xuplims=False,errorevery=1,capthick=None,data=None,**kwargs)[source]#

Plot y versus x as lines and/or markers with attached errorbars.

x,y define the data locations,xerr,yerr define the errorbarsizes. By default, this draws the data markers/lines as well as theerrorbars. Use fmt='none' to draw errorbars without any data markers.

Added in version 3.7:Caps and error lines are drawn in polar coordinates on polar plots.

Parameters:
x, yfloat or array-like

The data positions.

xerr, yerrfloat or array-like, shape(N,) or shape(2, N), optional

The errorbar sizes:

  • scalar: Symmetric +/- values for all data points.

  • shape(N,): Symmetric +/-values for each data point.

  • shape(2, N): Separate - and + values for each bar. First rowcontains the lower errors, the second row contains the uppererrors.

  • None: No errorbar.

All values must be >= 0.

SeeDifferent ways of specifying error barsfor an example on the usage ofxerr andyerr.

fmtstr, default: ''

The format for the data points / data lines. Seeplot fordetails.

Use 'none' (case-insensitive) to plot errorbars without any datamarkers.

ecolorcolor, default: None

The color of the errorbar lines. If None, use the color of theline connecting the markers.

elinewidthfloat, default: None

The linewidth of the errorbar lines. If None, the linewidth ofthe current style is used.

capsizefloat, default:rcParams["errorbar.capsize"] (default:0.0)

The length of the error bar caps in points.

capthickfloat, default: None

An alias to the keyword argumentmarkeredgewidth (a.k.a.mew).This setting is a more sensible name for the property thatcontrols the thickness of the error bar cap in points. Forbackwards compatibility, ifmew ormarkeredgewidth are given,then they will over-ridecapthick. This may change in futurereleases.

barsabovebool, default: False

If True, will plot the errorbars above the plotsymbols. Default is below.

lolims, uplims, xlolims, xuplimsbool or array-like, default: False

These arguments can be used to indicate that a value gives onlyupper/lower limits. In that case a caret symbol is used toindicate this.lims-arguments may be scalars, or array-likes ofthe same length asxerr andyerr. To use limits with invertedaxes,set_xlim orset_ylim must be called beforeerrorbar(). Note the tricky parameter names: setting e.g.lolims to True means that the y-value is alower limit of theTrue value, so, only anupward-pointing arrow will be drawn!

erroreveryint or (int, int), default: 1

draws error bars on a subset of the data.errorevery =N drawserror bars on the points (x[::N], y[::N]).errorevery =(start, N) draws error bars on the points(x[start::N], y[start::N]). e.g. errorevery=(6, 3)adds error bars to the data at (x[6], x[9], x[12], x[15], ...).Used to avoid overlapping error bars when two series share x-axisvalues.

Returns:
ErrorbarContainer

The container contains:

  • data_line : ALine2D instance of x, y plot markersand/or line.

  • caplines : A tuple ofLine2D instances of the errorbar caps.

  • barlinecols : A tuple ofLineCollection with the horizontal andvertical error ranges.

Other Parameters:
dataindexable object, optional

If given, the following parameters also accept a strings, which isinterpreted asdata[s] ifs is a key indata:

x,y,xerr,yerr

**kwargs

All other keyword arguments are passed on to theplot calldrawing the markers. For example, this code makes big red squareswith thick green edges:

x,y,yerr=rand(3,10)errorbar(x,y,yerr,marker='s',mfc='red',mec='green',ms=20,mew=4)

wheremfc,mec,ms andmew are aliases for the longerproperty names,markerfacecolor,markeredgecolor,markersizeandmarkeredgewidth.

Valid kwargs for the marker properties are:

  • dashes

  • dash_capstyle

  • dash_joinstyle

  • drawstyle

  • fillstyle

  • linestyle

  • marker

  • markeredgecolor

  • markeredgewidth

  • markerfacecolor

  • markerfacecoloralt

  • markersize

  • markevery

  • solid_capstyle

  • solid_joinstyle

Refer to the correspondingLine2D property for more details:

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

float or None

animated

bool

antialiased oraa

bool

clip_box

BboxBase or None

clip_on

bool

clip_path

Patch or (Path, Transform) or None

color orc

color

dash_capstyle

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

dash_joinstyle

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

dashes

sequence of floats (on/off ink in points) or (None, None)

data

(2, N) array or two 1D arrays

drawstyle ords

{'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'}, default: 'default'

figure

Figure orSubFigure

fillstyle

{'full', 'left', 'right', 'bottom', 'top', 'none'}

gapcolor

color or None

gid

str

in_layout

bool

label

object

linestyle orls

{'-', '--', '-.', ':', '', (offset, on-off-seq), ...}

linewidth orlw

float

marker

marker style string,Path orMarkerStyle

markeredgecolor ormec

color

markeredgewidth ormew

float

markerfacecolor ormfc

color

markerfacecoloralt ormfcalt

color

markersize orms

float

markevery

None or int or (int, int) or slice or list[int] or float or (float, float) or list[bool]

mouseover

bool

path_effects

list ofAbstractPathEffect

picker

float or callable[[Artist, Event], tuple[bool, dict]]

pickradius

float

rasterized

bool

sketch_params

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

snap

bool or None

solid_capstyle

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

solid_joinstyle

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

transform

unknown

url

str

visible

bool

xdata

1D array

ydata

1D array

zorder

float

Examples usingmatplotlib.axes.Axes.errorbar#

Parasite Simple2

Parasite Simple2

Errorbar limit selection

Errorbar limit selection

Errorbar subsampling

Errorbar subsampling

3D errorbars

3D errorbars

Error bar rendering on polar axis

Error bar rendering on polar axis

Log scale

Log scale

Errorbar function

Errorbar function

Different ways of specifying error bars

Different ways of specifying error bars

Including upper and lower limits in error bars

Including upper and lower limits in error bars

Create boxes from error bars using PatchCollection

Create boxes from error bars using PatchCollection

Legend Demo

Legend Demo

errorbar(x, y, yerr, xerr)

errorbar(x, y, yerr, xerr)