Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 91bcd07

Browse filesBrowse files
committed
Have px honor the symbol sequence and line dash sequence from template
if one is present
1 parent d23a90f commit 91bcd07
Copy full SHA for 91bcd07

File tree

Expand file treeCollapse file tree

1 file changed

+33
-4
lines changed
Filter options
  • packages/python/plotly/plotly/express
Expand file treeCollapse file tree

1 file changed

+33
-4
lines changed

‎packages/python/plotly/plotly/express/_core.py

Copy file name to clipboardExpand all lines: packages/python/plotly/plotly/express/_core.py
+33-4Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ def __init__(self):
1919
self.height = 600
2020
self.color_discrete_sequence = None
2121
self.color_continuous_scale = None
22-
self.symbol_sequence = ["circle", "diamond", "square", "x", "cross"]
23-
self.line_dash_sequence = ["solid", "dot", "dash", "longdash", "dashdot"] + [
24-
"longdashdot"
25-
]
22+
self.symbol_sequence = None
23+
self.line_dash_sequence = None
2624
self.size_max = 20
2725

2826

@@ -673,6 +671,37 @@ def apply_default_cascade(args):
673671
if args["color_discrete_sequence"] is None:
674672
args["color_discrete_sequence"] = qualitative.D3
675673

674+
# if symbol_sequence/line_dash_sequence not set explicitly or in px.defaults,
675+
# see if we can defer to template. If not, set reasonable defaults
676+
if "symbol_sequence" in args:
677+
if args["symbol_sequence"] is None:
678+
try:
679+
args["symbol_sequence"] = [
680+
scatter.marker.symbol for scatter in template.data.scatter
681+
]
682+
except (AttributeError, TypeError):
683+
pass
684+
if not args["symbol_sequence"] or not any(args["symbol_sequence"]):
685+
args["symbol_sequence"] = ["circle", "diamond", "square", "x", "cross"]
686+
687+
if "line_dash_sequence" in args:
688+
if args["line_dash_sequence"] is None:
689+
try:
690+
args["line_dash_sequence"] = [
691+
scatter.line.dash for scatter in template.data.scatter
692+
]
693+
except (AttributeError, TypeError):
694+
pass
695+
if not args["line_dash_sequence"] or not any(args["line_dash_sequence"]):
696+
args["line_dash_sequence"] = [
697+
"solid",
698+
"dot",
699+
"dash",
700+
"longdash",
701+
"dashdot",
702+
"longdashdot",
703+
]
704+
676705
# If both marginals and faceting are specified, faceting wins
677706
if args.get("facet_col", None) and args.get("marginal_y", None):
678707
args["marginal_y"] = None

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.