Single-variable distribution analysis
Inspecting the distribution of measurements or transaction values.
Plotly · Function
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.
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.
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)| Name | Type | Description |
|---|---|---|
data_frame | DataFrame or array-like | Data frame or array-like data used to construct the ECDF. |
x | str, list[str], or array-like | Column name, list of column names, or array-like values to distribute along the x-axis. |
color | str or sequence | Column used to split observations into colored ECDF traces. |
ecdfnorm | str or None | Normalization of the ECDF y-axis, such as probability, raw counts, or percent. |
markers | bool | Whether to display markers at ECDF points. |
ecdfmode | str | Cumulative direction, including standard or reversed mode. |
A plotly.graph_objects.Figure containing the ECDF visualization.
px.ecdf() as Plotly Express's built-in constructor for empirical cumulative distribution plots.x column is enough to create a basic ECDF.ecdfnorm=None when the y-axis should show observation counts instead of normalized probability.ecdfnorm="percent" to express cumulative values as percentages.x can generate ECDFs for multiple data series.markers=True adds markers, while ecdfmode="standard" selects the ordinary cumulative direction.ecdfnorm=None for counts or ecdfnorm="percent" for percentages.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.
Inspecting the distribution of measurements or transaction values.
Comparing cumulative distributions for groups such as sexes, regions, or experiment arms.
Showing several columns or variables on a common cumulative-distribution view.
Communicating counts or percentage thresholds rather than probabilities.
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.
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.
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.scatterplotly.express.boxfacet_rowfacet_colplotly.graph_objects.Figure