diff --git a/CHANGELOG.md b/CHANGELOG.md index 4673caf3790..4f34484ea67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [UNRELEASED] ### Fixed +- Ensure scatter `mode` is deterministic from `px` [[#4429](https://github.com/plotly/plotly.py/pull/4429)] - Fix issue with creating dendrogram in subplots [[#4411](https://github.com/plotly/plotly.py/pull/4411)], -- Fix issue with px.line not accepting "spline" line shape [[#2812](https://github.com/plotly/plotly.py/issues/2812)], +- Fix issue with px.line not accepting "spline" line shape [[#2812](https://github.com/plotly/plotly.py/issues/2812)] ## [5.18.0] - 2023-10-25 diff --git a/packages/python/plotly/plotly/express/_core.py b/packages/python/plotly/plotly/express/_core.py index 5de16add69a..b80355c727d 100644 --- a/packages/python/plotly/plotly/express/_core.py +++ b/packages/python/plotly/plotly/express/_core.py @@ -1929,7 +1929,7 @@ def infer_config(args, constructor, trace_patch, layout_patch): modes.add("text") if len(modes) == 0: modes.add("lines") - trace_patch["mode"] = "+".join(modes) + trace_patch["mode"] = "+".join(sorted(modes)) elif constructor != go.Splom and ( "symbol" in args or constructor == go.Scattermapbox ): diff --git a/packages/python/plotly/plotly/tests/test_optional/test_px/test_px.py b/packages/python/plotly/plotly/tests/test_optional/test_px/test_px.py index 6650cdd6742..8bcff763ab2 100644 --- a/packages/python/plotly/plotly/tests/test_optional/test_px/test_px.py +++ b/packages/python/plotly/plotly/tests/test_optional/test_px/test_px.py @@ -80,6 +80,26 @@ def test_labels(): assert fig.layout.annotations[4].text.startswith("TIME") +@pytest.mark.parametrize( + ["extra_kwargs", "expected_mode"], + [ + ({}, "lines"), + ({"markers": True}, "lines+markers"), + ({"text": "continent"}, "lines+markers+text"), + ], +) +def test_line_mode(extra_kwargs, expected_mode): + gapminder = px.data.gapminder() + fig = px.line( + gapminder, + x="year", + y="pop", + color="country", + **extra_kwargs, + ) + assert fig.data[0].mode == expected_mode + + def test_px_templates(): try: import plotly.graph_objects as go