Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Fix `px.sunburst`, `px.treemap` and `px.icicle` listing sectors in a different order on every run when `path` is used with a Polars DataFrame; sectors now follow their order of first appearance for all dataframe backends [[#5766](https://github.com/plotly/plotly.py/pull/5766)], with thanks to @Irahan2 for the contribution!
- Fix `mpl_to_plotly` conversion of matplotlib contour lines and line collections: close contour rings ending with `Z` codes, support dash styles, convert date x-axes, separate disjoint subpaths with `None` separators, hide line collection traces from the legend by default, and group consecutive same-style lines into single traces [[#5770](https://github.com/plotly/plotly.py/pull/5770)], with thanks to @robertoffmoura for the contribution!
- Fix serialization of box/lasso select data for figures with multiple subplots [[#5710](https://github.com/plotly/plotly.py/pull/5710)], with thanks to @flpi-sun for the contribution!
- Fix `px.ecdf` counting rows with a missing value as observations, so the curve no longer stops short of 1 (or 100%) and no longer adds a point at a missing x [[#5842](https://github.com/plotly/plotly.py/pull/5842)]

## [7.1.0] - 2026-09-15

Expand Down
2 changes: 2 additions & 0 deletions plotly/express/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2710,6 +2710,8 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
base = args["x"] if args["orientation"] == "v" else args["y"]
var = args["x"] if args["orientation"] == "h" else args["y"]
ascending = args.get("ecdfmode", "standard") != "reversed"
# missing values are not observations: exclude them from the ECDF
group = group.filter(~nw.col(base).is_null())
group = group.sort(by=base, descending=not ascending, nulls_last=True)
group_sum = group.get_column(
var
Expand Down
17 changes: 17 additions & 0 deletions tests/test_optional/test_px/test_px_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,3 +688,20 @@ def test_empty_histogram():
fig = px.histogram()
assert len(fig.data) == 1
assert fig.data[0].type == "histogram"


@pytest.mark.parametrize(
"ecdfmode,expected",
[
("standard", [1 / 3, 2 / 3, 1]),
("complementary", [2 / 3, 1 / 3, 0]),
("reversed", [1, 2 / 3, 1 / 3]),
],
)
def test_ecdf_ignores_missing_values(constructor, ecdfmode, expected):
# a missing value is not an observation: it must not count towards the total
# or produce a point of its own
data = constructor({"value": [3.0, 1.0, 2.0, None]})
fig = px.ecdf(data, x="value", ecdfmode=ecdfmode)
assert_array_equal(fig.data[0].x, [1.0, 2.0, 3.0])
assert np.allclose(fig.data[0].y, expected)