Skip to content

Commit

Permalink
Merge pull request #401 from openego/bugfix/matplotlib_attribute_error
Browse files Browse the repository at this point in the history
Fix: Correct Matplotlib Attribute Error
  • Loading branch information
birgits authored Jul 11, 2024
2 parents 0374224 + 97afc73 commit 84bc40e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions edisgo/tools/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from typing import TYPE_CHECKING

import matplotlib
import matplotlib.cm as cm
import numpy as np
import pandas as pd
import plotly.graph_objects as go
Expand Down Expand Up @@ -604,7 +603,7 @@ def nodes_by_costs(buses, grid_expansion_costs, edisgo_obj):
bus_sizes, bus_colors = nodes_by_costs(
pypsa_plot.buses.index, grid_expansion_costs, edisgo_obj
)
bus_cmap = plt.cm.get_cmap(lines_cmap)
bus_cmap = matplotlib.pyplot.colormaps.get_cmap(lines_cmap)
elif node_color == "curtailment":
bus_sizes = nodes_curtailment(pypsa_plot.buses.index, curtailment_df)
bus_colors = "orangered"
Expand Down Expand Up @@ -681,7 +680,8 @@ def nodes_by_costs(buses, grid_expansion_costs, edisgo_obj):
line_width = pypsa_plot.lines.s_nom * scaling_factor_line_width
else:
line_width = 2
cmap = plt.cm.get_cmap(lines_cmap)
cmap = matplotlib.pyplot.colormaps.get_cmap(lines_cmap)

ll = pypsa_plot.plot(
line_colors=line_colors,
line_cmap=cmap,
Expand Down Expand Up @@ -888,7 +888,7 @@ def color_map_color(
"""
norm = matplotlib.colors.Normalize(vmin=vmin, vmax=vmax)
if isinstance(cmap_name, str):
cmap = cm.get_cmap(cmap_name)
cmap = matplotlib.pyplot.colormaps.get_cmap(cmap_name)
else:
cmap = matplotlib.colors.LinearSegmentedColormap.from_list("mycmap", cmap_name)
rgb = cmap(norm(abs(value)))[:3]
Expand Down

0 comments on commit 84bc40e

Please sign in to comment.