Skip to content
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions src/plots/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,9 @@
from nowcasting_datamodel.read.read_models import get_models
import os
from datetime import datetime, timedelta
import plotly.express as px

line_color = [
"#9EC8FA",
"#9AA1F9",
"#FFAC5F",
"#9F973A",
"#7BCDF3",
"#086788",
"#63BCAF",
"#4C9A8E",
]
PALETTE = px.colors.qualitative.Dark24

colour_per_model = {
"cnn": "#FFD053",
Expand All @@ -28,7 +20,6 @@

# Make a cycle for extra models not in colour_per_model
# Skip first 3 colours as they are too similar to colours in colour_per_model
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should be removed too as the line it related to has been removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

line_color_cycle = cycle(line_color[3:])

def hex_to_rgb(value):
value = value.lstrip("#")
Expand All @@ -39,14 +30,15 @@ def hex_to_rgb(value):
def get_colour_from_model_name(model_name, opacity=1.0):
"""Get colour from model label"""
if "PVLive" in model_name:
colour = colour_per_model.get(model_name, "#FFFFFF")
return colour_per_model.get(model_name, "#FFFFFF")
else:
# Some models have a space and a datetime
model_name_only = model_name.split(" ")[0]
if model_name_only in colour_per_model:
colour = colour_per_model[model_name_only]
else:
colour = next(line_color_cycle)
idx = abs(hash(model_name_only)) % len(PALETTE)
colour = PALETTE[idx]
colour_per_model[model_name_only] = colour
return colour

Expand Down