Skip to content

Commit

Permalink
Merge pull request #146 from agoenergy/discrete_colors_cost_categories
Browse files Browse the repository at this point in the history
use discrete color map for cost category barplots
  • Loading branch information
markushal authored Nov 30, 2023
2 parents 25f32eb + dda7300 commit 20388e6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion app/plot_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 20388e6

Please sign in to comment.