Skip to content

Commit f3e7c5a

Browse files
author
Sarah Krebs
committed
Fix error when requesting more than 10 colors
1 parent fea1a2a commit f3e7c5a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Bug-Fixes
44
- Fix seaborn style name (#82).
5+
- Fix error when requesting more than 10 colors in a plot (36 colors available now).
56

67
# Version 1.1.2
78

deepcave/utils/styled_plotty.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,12 @@ def hex_to_rgb(hex_string: str) -> Tuple[int, int, int]:
6969

7070
def get_color(id_: int, alpha: float = 1) -> Union[str, Tuple[float, float, float, float]]:
7171
"""
72-
Currently (Plotly version 5.3.1) there are 10 possible colors.
72+
Using Plotly palette for the first 10 ids and Alphabet palette for the next 26, currently 36 colors are possible.
7373
"""
74-
color = px.colors.qualitative.Plotly[id_]
74+
if id_ < 10:
75+
color = px.colors.qualitative.Plotly[id_]
76+
else:
77+
color = px.colors.qualitative.Alphabet[id_ % 10]
7578

7679
r, g, b = hex_to_rgb(color)
7780
return f"rgba({r}, {g}, {b}, {alpha})"

0 commit comments

Comments
 (0)