Skip to content

Commit

Permalink
Fix error when requesting more than 10 colors
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarah Krebs committed Oct 27, 2023
1 parent fea1a2a commit f3e7c5a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

# Version 1.1.2

Expand Down
7 changes: 5 additions & 2 deletions deepcave/utils/styled_plotty.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ def hex_to_rgb(hex_string: str) -> Tuple[int, int, int]:

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

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

0 comments on commit f3e7c5a

Please sign in to comment.