From d4c6521aaf1f29d7fa8880ab42da4ced58e467aa Mon Sep 17 00:00:00 2001 From: Tom Brown Date: Fri, 31 Jan 2020 19:20:46 +0100 Subject: [PATCH] For H2 network plotting, introduce dummy MultiIndex to get area Otherwise the area is not consistent with the legend (I'll open a PyPSA issue). --- scripts/plot_network.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/plot_network.py b/scripts/plot_network.py index a3a1d029..9baa07d4 100644 --- a/scripts/plot_network.py +++ b/scripts/plot_network.py @@ -219,7 +219,7 @@ def plot_h2_map(): assign_location(n) - bus_size_factor=5e2 + bus_size_factor=1e5 linewidth_factor=1e4 #MW below which not drawn line_threshold=1e3 @@ -234,6 +234,9 @@ def plot_h2_map(): bus_sizes = pd.Series(0., index=n.buses.index) bus_sizes.loc[elec.str.replace(" H2 Electrolysis","")] = n.links.loc[elec,"p_nom_opt"].values/bus_size_factor + #make a fake MultiIndex so that area is correct for legend + bus_sizes.index = pd.MultiIndex.from_product([bus_sizes.index,["electrolysis"]]) + n.links.drop(n.links.index[n.links.carrier != "H2 pipeline"],inplace=True) link_widths = n.links.p_nom_opt/linewidth_factor @@ -251,13 +254,13 @@ def plot_h2_map(): fig.set_size_inches(7,6) n.plot(bus_sizes=bus_sizes, - bus_colors=bus_color, + bus_colors={"electrolysis" : bus_color}, line_colors=dict(Link=link_color), line_widths={"Link" : link_widths}, branch_components=["Link"], ax=ax) - handles = make_legend_circles_for([50, 10], scale=bus_size_factor, facecolor=bus_color) + handles = make_legend_circles_for([50000, 10000], scale=bus_size_factor, facecolor=bus_color) labels = ["{} GW".format(s) for s in (50, 10)] l2 = ax.legend(handles, labels, loc="upper left", bbox_to_anchor=(0.01, 1.01),