Skip to content

Commit d4a7c32

Browse files
authored
Merge pull request #4429 from alev000/sort-modes
Deterministic sort order for plotly express modes
2 parents 38ded4a + f68a164 commit d4a7c32

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

Diff for: CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55
## [UNRELEASED]
66

77
### Fixed
8+
- Ensure scatter `mode` is deterministic from `px` [[#4429](https://github.com/plotly/plotly.py/pull/4429)]
89
- Fix issue with creating dendrogram in subplots [[#4411](https://github.com/plotly/plotly.py/pull/4411)],
9-
- Fix issue with px.line not accepting "spline" line shape [[#2812](https://github.com/plotly/plotly.py/issues/2812)],
10+
- Fix issue with px.line not accepting "spline" line shape [[#2812](https://github.com/plotly/plotly.py/issues/2812)]
1011

1112
## [5.18.0] - 2023-10-25
1213

Diff for: packages/python/plotly/plotly/express/_core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1929,7 +1929,7 @@ def infer_config(args, constructor, trace_patch, layout_patch):
19291929
modes.add("text")
19301930
if len(modes) == 0:
19311931
modes.add("lines")
1932-
trace_patch["mode"] = "+".join(modes)
1932+
trace_patch["mode"] = "+".join(sorted(modes))
19331933
elif constructor != go.Splom and (
19341934
"symbol" in args or constructor == go.Scattermapbox
19351935
):

Diff for: packages/python/plotly/plotly/tests/test_optional/test_px/test_px.py

+20
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,26 @@ def test_labels():
8080
assert fig.layout.annotations[4].text.startswith("TIME")
8181

8282

83+
@pytest.mark.parametrize(
84+
["extra_kwargs", "expected_mode"],
85+
[
86+
({}, "lines"),
87+
({"markers": True}, "lines+markers"),
88+
({"text": "continent"}, "lines+markers+text"),
89+
],
90+
)
91+
def test_line_mode(extra_kwargs, expected_mode):
92+
gapminder = px.data.gapminder()
93+
fig = px.line(
94+
gapminder,
95+
x="year",
96+
y="pop",
97+
color="country",
98+
**extra_kwargs,
99+
)
100+
assert fig.data[0].mode == expected_mode
101+
102+
83103
def test_px_templates():
84104
try:
85105
import plotly.graph_objects as go

0 commit comments

Comments
 (0)