matplotlib.pyplot.ecdf#

matplotlib.pyplot.ecdf(x,weights=None,*,complementary=False,orientation='vertical',compress=False,data=None,**kwargs)[source]#

Compute and plot the empirical cumulative distribution function ofx.

Added in version 3.8.

Parameters:
x1d array-like

The input data. Infinite entries are kept (and move the relevantend of the ecdf from 0/1), but NaNs and masked values are errors.

weights1d array-like or None, default: None

The weights of the entries; must have the same shape asx.Weights corresponding to NaN data points are dropped, and then theremaining weights are normalized to sum to 1. If unset, allentries have the same weight.

complementarybool, default: False

Whether to plot a cumulative distribution function, which increasesfrom 0 to 1 (the default), or a complementary cumulativedistribution function, which decreases from 1 to 0.

orientation{"vertical", "horizontal"}, default: "vertical"

Whether the entries are plotted along the x-axis ("vertical", thedefault) or the y-axis ("horizontal"). This parameter takes thesame values as inhist.

compressbool, default: False

Whether multiple entries with the same values are grouped together(with a summed weight) before plotting. This is mainly useful ifx contains many identical data points, to decrease the renderingcomplexity of the plot. Ifx contains no duplicate points, thishas no effect and just uses some time and memory.

Returns:
Line2D
Other Parameters:
dataindexable object, optional

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

x,weights

**kwargs

Keyword arguments control theLine2D properties:

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

Notes

Note

This is thepyplot wrapper foraxes.Axes.ecdf.

The ecdf plot can be thought of as a cumulative histogram with one binper data entry; i.e. it reports on the entire dataset without anyarbitrary binning.

Ifx contains NaNs or masked entries, either remove them first fromthe array (if they should not taken into account), or replace them by-inf or +inf (if they should be sorted at the beginning or the end ofthe array).

Examples usingmatplotlib.pyplot.ecdf#

Cumulative distributions

Cumulative distributions