Compute and plot the empirical cumulative distribution function of x.
Added in version 3.8.
The input data. Infinite entries are kept (and move the relevant end of the ecdf from 0/1), but NaNs and masked values are errors.
The weights of the entries; must have the same shape as x. Weights corresponding to NaN data points are dropped, and then the remaining weights are normalized to sum to 1. If unset, all entries have the same weight.
Whether to plot a cumulative distribution function, which increases from 0 to 1 (the default), or a complementary cumulative distribution function, which decreases from 1 to 0.
Whether the entries are plotted along the x-axis ("vertical", the default) or the y-axis ("horizontal"). This parameter takes the same values as in hist.
Whether multiple entries with the same values are grouped together (with a summed weight) before plotting. This is mainly useful if x contains many identical data points, to decrease the rendering complexity of the plot. If x contains no duplicate points, this has no effect and just uses some time and memory.
If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception):
x, weights
Keyword arguments control the Line2D properties:
Property | Description |
|---|---|
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 | |
scalar or None | |
bool | |
| bool |
| |
bool | |
Patch or (Path, Transform) or None | |
| |
| |
| |
sequence of floats (on/off ink in points) or (None, None) | |
(2, N) array or two 1D arrays | |
| {'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'}, default: 'default' |
{'full', 'left', 'right', 'bottom', 'top', 'none'} | |
color or None | |
str | |
bool | |
object | |
| {'-', '--', '-.', ':', '', (offset, on-off-seq), ...} |
| float |
marker style string, | |
| |
| float |
| |
| |
| float |
None or int or (int, int) or slice or list[int] or float or (float, float) or list[bool] | |
bool | |
list of | |
float or callable[[Artist, Event], tuple[bool, dict]] | |
float | |
bool | |
(scale: float, length: float, randomness: float) | |
bool or None | |
| |
| |
unknown | |
str | |
bool | |
1D array | |
1D array | |
float |
Note
This is the pyplot wrapper for axes.Axes.ecdf.
The ecdf plot can be thought of as a cumulative histogram with one bin per data entry; i.e. it reports on the entire dataset without any arbitrary binning.
If x contains NaNs or masked entries, either remove them first from the 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 of the array).
matplotlib.pyplot.ecdf
© 2012–2023 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.ecdf.html