matplotlib.pyplot.errorbar — Matplotlib 3.10.1 documentation (original) (raw)

matplotlib.pyplot.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 errorbar sizes. By default, this draws the data markers/lines as well as the errorbars. 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:

All values must be >= 0.

See Different ways of specifying error barsfor an example on the usage of xerr and yerr.

fmtstr, default: ''

The format for the data points / data lines. See plot for details.

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

ecolorcolor, default: None

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

elinewidthfloat, default: None

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

capsizefloat, default: [rcParams["errorbar.capsize"]](../../users/explain/customizing.html?highlight=errorbar.capsize#matplotlibrc-sample) (default: 0.0)

The length of the error bar caps in points.

capthickfloat, default: None

An alias to the keyword argument markeredgewidth (a.k.a. mew). This setting is a more sensible name for the property that controls the thickness of the error bar cap in points. For backwards compatibility, if mew or markeredgewidth are given, then they will over-ride capthick. This may change in future releases.

barsabovebool, default: False

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

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

These arguments can be used to indicate that a value gives only upper/lower limits. In that case a caret symbol is used to indicate this. _lims_-arguments may be scalars, or array-likes of the same length as xerr and yerr. To use limits with inverted axes, set_xlim or set_ylim must be called beforeerrorbar(). Note the tricky parameter names: setting e.g.lolims to True means that the y-value is a lower limit of the True value, so, only an _upward_-pointing arrow will be drawn!

erroreveryint or (int, int), default: 1

draws error bars on a subset of the data. errorevery =N draws error 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-axis values.

Returns:

ErrorbarContainer

The container contains:

Other Parameters:

dataindexable object, optional

If given, the following parameters also accept a string s, which is interpreted as data[s] if s is a key in data:

x, y, xerr, yerr

**kwargs

All other keyword arguments are passed on to the plot call drawing the markers. For example, this code makes big red squares with thick green edges:

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

where mfc, mec, ms and mew are aliases for the longer property names, markerfacecolor, markeredgecolor, _markersize_and markeredgewidth.

Valid kwargs for the marker properties are:

Refer to the corresponding Line2D property for more details:

Notes

Examples using matplotlib.pyplot.errorbar#