Skip to content

Commit

Permalink
Merge pull request #4429 from alev000/sort-modes
Browse files Browse the repository at this point in the history
Deterministic sort order for plotly express modes
  • Loading branch information
alexcjohnson committed Nov 17, 2023
2 parents 38ded4a + f68a164 commit d4a7c32
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion packages/python/plotly/plotly/express/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d4a7c32

Please sign in to comment.