Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Plotly · Function

px.ecdf

px.ecdf creates an empirical cumulative distribution function plot from tabular or array-like data. It supports category-based comparisons, multiple distributions, normalization choices, markers, and standard or reversed cumulative modes.

How it works

px.ecdf sorts observations along the selected variable and draws the empirical cumulative distribution, optionally splitting curves by categories or facets. Its normalization can represent probability, raw counts, or percentages, while markers and alternate ECDF modes adjust the visual encoding.

Syntax

plotly.express.ecdf(data_frame=None, x=None, y=None, color=None, text=None, symbol=None, line_dash=None, width=None, height=None, facet_row=None, facet_col=None, facet_col_wrap=0, facet_row_spacing=None, facet_col_spacing=None, hover_name=None, hover_data=None, custom_data=None, animation_frame=None, animation_group=None, category_orders=None, labels=None, color_discrete_sequence=None, color_discrete_map=None, color_discrete原=None, log_x=False, log_y=False, range_x=None, range_y=None, title=None, template=None, width=None, height=None, render_mode='auto', ecdfnorm='probability', ecdfmode='standard', markers=False)

Parameters

NameTypeDescription
data_frameDataFrame or array-likeData frame or array-like data used to construct the ECDF.
xstr, list[str], or array-likeColumn name, list of column names, or array-like values to distribute along the x-axis.
colorstr or sequenceColumn used to split observations into colored ECDF traces.
ecdfnormstr or NoneNormalization of the ECDF y-axis, such as probability, raw counts, or percent.
markersboolWhether to display markers at ECDF points.
ecdfmodestrCumulative direction, including standard or reversed mode.

Returns

A plotly.graph_objects.Figure containing the ECDF visualization.

Key points

  • Use px.ecdf() as Plotly Express's built-in constructor for empirical cumulative distribution plots.
  • A single x column is enough to create a basic ECDF.
  • Set ecdfnorm=None when the y-axis should show observation counts instead of normalized probability.
  • Set ecdfnorm="percent" to express cumulative values as percentages.
  • An array of column names supplied to x can generate ECDFs for multiple data series.
  • markers=True adds markers, while ecdfmode="standard" selects the ordinary cumulative direction.

Common mistakes

  • The default vertical scale is probability; select ecdfnorm=None for counts or ecdfnorm="percent" for percentages.

Example: Percentage ECDF by category

import plotly.express as px

df = px.data.tips()
fig = px.ecdf(df, x="total_bill", color="sex", ecdfnorm="percent")
fig.show()

Creates a percentage-normalized ECDF of tip data, with separate curves by sex.

When to use it

Single-variable distribution analysis

Inspecting the distribution of measurements or transaction values.

Category comparison

Comparing cumulative distributions for groups such as sexes, regions, or experiment arms.

Multiple-series comparison

Showing several columns or variables on a common cumulative-distribution view.

Alternative normalization

Communicating counts or percentage thresholds rather than probabilities.

Interview questions

QWhat does px.ecdf visualize, and what can be passed to x?

px.ecdf produces an empirical cumulative distribution function plot from rows in a data frame or directly supplied values. With one x column it creates a basic ECDF; multiple columns can be supplied to x for multiple distributions.

Follow-up: How would you change the vertical scale? Set ecdfnorm to None for raw counts or to "percent" for percentages.

QHow do you compare distributions across categories?

Use color to create separate ECDF curves for categories. The function also supports Plotly Express grouping and faceting arguments, allowing distributions to be compared across subsets.

Follow-up: How could you display each category in separate panels? Pass a grouping variable to facet_row or facet_col.

QHow can the resulting ECDF be customized?

The function returns a Plotly figure that can be displayed with fig.show() and further customized using Plotly figure methods. The example documentation demonstrates enabling point markers with markers=True and selecting an ECDF mode.

Follow-up: What alternate cumulative direction is available? Use ecdfmode="reversed" to show the fraction at or above each x value.

  • plotly.express.scatter
  • plotly.express.box
  • facet_row
  • facet_col
  • plotly.graph_objects.Figure

Source: Empirical cumulative distribution plots in Python. Checked 2026-10-15.