Chart Gallery

/

ECDF Plot in Python

ECDF Plots in Python

An ECDF plot (also called an ECDF graph) shows the empirical cumulative distribution function of a sample: for each value it shows the fraction of observations at or below it, rising from 0 to 1. With xy you build an empirical cdf in Python that reads percentiles straight off the curve and stays interactive — pan, zoom, and hover across thousands of points.

Jump to creating an ECDF, reading percentiles, or options.

Create an ECDF

Pass a 1-D array of samples to ecdf. This is the minimal Python ECDF:

Compare Two Distributions

Overlay one ecdf mark per sample with name= labels, a dash style to tell the curves apart, and a legend() — a horizontal gap between the curves reads directly as a shift in that percentile:

Large Samples with Bounded Bins

For very large inputs, set bins to draw a bounded approximation instead of an exact step per observation — here 500,000 points collapse to 512 steps while width and opacity style the curve and the y-axis is pinned to (0, 1):

Reading Percentiles

An ECDF makes percentiles direct to read: find a fraction on the y-axis and trace across to the curve to get that percentile's value, or start from a value on the x-axis to see what fraction of the data falls below it. Because the curve uses every observation, it avoids the binning choices a histogram forces, so the shape never depends on a bin count.

ECDF Options

OptionPurpose
binsBounded approximation for very large inputs; omit for an exact ECDF.
colorCurve color (any CSS color).
widthStroke width in pixels.
opacityCurve opacity from 0 to 1.
nameSeries label shown in the legend().

Pass a column name with data= instead of an array when your data is a table.

  • Histograms — bin the same distribution into bars.
  • Box plots — summarize a distribution with quartiles.

API Reference

xy.ecdf_chart

An ECDF chart composing `ecdf` marks.

Props

PropTypeDescription
*childrenComponent

Marks, axes, annotations, and chart chrome.

titleOptional[str]

Title shown above the plot.

widthint | str

Chart width in pixels or a CSS size such as ``"100%"``.

heightint | str

Chart height in pixels or a CSS size such as ``"100%"``.

paddingUnion[float, Sequence[float], None]

Plot margins, as one value or a sequence of side values. Use zero for an edge-to-edge sparkline.

dataTableLike

Chart-level data used by marks that omit their own ``data``.

class_nameOptional[str]

CSS class applied to the chart container.

class_namesOptional[dict[str, str]]

CSS classes keyed by stable chart DOM slot.

styleOptional[dict[str, StyleValue]]

Inline style overrides for the chart container.

stylesOptional[dict[str, dict[str, StyleValue]]]

Inline style mappings keyed by stable chart DOM slot.

on_hoverOptional[Callable[[dict], None]]

Callback receiving hover event payloads.

on_clickOptional[Callable[[dict], None]]

Callback receiving picked-mark click payloads.

on_brushOptional[Callable[[dict], None]]

Callback receiving brush event payloads.

on_selectOptional[Callable[[Selection], None]]

Callback receiving data-space selections.

on_view_changeOptional[Callable[[dict], None]]

Callback receiving viewport change payloads.

hoverOptional[bool]

Whether pointer movement emits hover events.

clickOptional[bool]

Whether picked marks emit click events.

selectOptional[bool]

Whether shift-drag box selection is enabled.

brushOptional[bool]

Whether brush selection is enabled.

crosshairOptional[bool]

Whether plot-aligned hover guides are shown.

navigationOptional[bool]

Whether browser pan and zoom navigation is enabled.

panOptional[bool]

Whether plain-drag panning is enabled.

pan_axesOptional[tuple[str, ...]]

Declared axis IDs translated by pan gestures.

zoomOptional[bool]

Whether viewport zoom is enabled.

default_drag_actionOptional[DefaultDragAction]

Initial action performed by a plain plot drag.

zoom_axesOptional[tuple[str, ...]]

Declared axis IDs changed by zoom gestures and controls.

zoom_limitsOptional[ZoomLimits]

Minimum and maximum magnification globally or by axis.

wheel_zoomOptional[bool]

Whether wheel and trackpad zoom is available.

box_zoomOptional[bool]

Whether box zoom is available as a drag action.

zoom_buttonsOptional[bool]

Whether modebar Zoom In/Out commands are available.

double_click_resetOptional[bool]

Whether double-click restores ``reset_axes``.

reset_axesOptional[tuple[str, ...]]

Declared axis IDs restored by reset.

link_groupOptional[str]

Identifier used to synchronize charts in the browser.

link_axesOptional[tuple[str, ...]]

Axes synchronized within the link group.

FAQ

How do I make an ECDF in Python?

Call xy.ecdf(values) inside xy.ecdf_chart(...) and render it. The ECDF chart handles the curve, axes, pan, zoom, and hover automatically.

What is an ECDF?

An empirical cumulative distribution function shows, for each value, the fraction of observations at or below it. It rises from 0 to 1 and uses every data point directly.

What is the difference between an ECDF and a histogram?

An ECDF is cumulative and bin-free, so its shape never depends on a bin count. A histogram shows counts per interval and depends on how many bins you choose.

How do I read percentiles from an ECDF?

Pick a fraction on the y-axis and trace across to the curve to get that percentile's value, or start from an x value to see the fraction of data below it.

Built with Reflex