From f3e7c5a62790dda49fbd503afada81962912cdda Mon Sep 17 00:00:00 2001 From: Sarah Krebs Date: Fri, 27 Oct 2023 15:22:45 +0200 Subject: [PATCH] Fix error when requesting more than 10 colors --- CHANGELOG.md | 1 + deepcave/utils/styled_plotty.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6b6d35b..de6fe8db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/deepcave/utils/styled_plotty.py b/deepcave/utils/styled_plotty.py index e4a0b4db..0cb6967c 100644 --- a/deepcave/utils/styled_plotty.py +++ b/deepcave/utils/styled_plotty.py @@ -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})"