Skip to content

Commit e7aa1b9

Browse files
committed
Deterministic sort order for plotly express modes
1 parent 38ded4a commit e7aa1b9

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

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
):

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)