Skip to content

Commit 36cb215

Browse files
ivaigultkernc
andauthored
Update backtesting/_plotting.py
Co-authored-by: kernc <[email protected]>
1 parent 8211d1b commit 36cb215

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

backtesting/_plotting.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -538,15 +538,18 @@ def __eq__(self, other):
538538
colors = colors and cycle(_as_list(colors)) or (
539539
cycle([next(ohlc_colors)]) if is_overlay else colorgen())
540540

541-
tooltip_label = value.name if isinstance(value.name, str) else ", ".join(value.name)
542-
543-
if isinstance(value.name, str) and len(value) > 1:
544-
legend_labels = [
545-
LegendStr(f"{name}[{index}]")
546-
for index, name in enumerate(repeat(value.name, len(value)))
547-
]
541+
if isinstance(value.name, str):
542+
tooltip_label = value.name
543+
if len(value) == 1:
544+
legend_labels = [LegendStr(value.name)]
545+
else:
546+
legend_labels = [
547+
LegendStr(f"{value.name}[{i}]")
548+
for i in enumerate(len(value))
549+
]
548550
else:
549-
legend_labels = [LegendStr(item) for item in _as_list(value.name)]
551+
tooltip_label = ", ".join(value.name)
552+
legend_labels = [LegendStr(item) for item in value.name]
550553

551554
for j, arr in enumerate(value):
552555
color = next(colors)

0 commit comments

Comments
 (0)