From dda7300a3532c07dcf6d769965ec10e3c9e14ea6 Mon Sep 17 00:00:00 2001 From: "j.aschauer" Date: Wed, 29 Nov 2023 09:30:08 +0100 Subject: [PATCH] use discrete color map for cost category barplots --- app/plot_functions.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/plot_functions.py b/app/plot_functions.py index 207ed705..492446e3 100644 --- a/app/plot_functions.py +++ b/app/plot_functions.py @@ -35,6 +35,21 @@ def agora_continuous_color_scale() -> list[tuple]: ] +def agora_discrete_colors_cost_categories() -> dict: + cost_categories = [ + "Water", + "Transportation (Ship)", + "Electrolysis", + "Electricity generation", + "Electricity and H2 storage", + "Derivate production", + "Heat", + "Carbon", + # TODO: add missing category (GH #145) + ] + return {c: st.session_state["colors"][i] for i, c in enumerate(cost_categories)} + + def plot_costs_on_map( api: PtxboaAPI, res_costs: pd.DataFrame, @@ -373,7 +388,7 @@ def create_bar_chart_costs(res_costs: pd.DataFrame, current_selection: str = Non x=res_costs.index, y=res_costs.columns[:-1], height=500, - color_discrete_sequence=st.session_state["colors"], + color_discrete_map=agora_discrete_colors_cost_categories(), ) # Add the dot markers for the "total" column using plotly.graph_objects