From 2ed521b4abd49bb504fa843c6ae5bf690dc7ab6d Mon Sep 17 00:00:00 2001 From: kaklise Date: Wed, 12 Jun 2024 09:51:42 -0700 Subject: [PATCH] bug fix in link colorbar, vmin and vmax value --- wntr/graphics/network.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wntr/graphics/network.py b/wntr/graphics/network.py index 45b420b13..4d479d683 100644 --- a/wntr/graphics/network.py +++ b/wntr/graphics/network.py @@ -228,8 +228,14 @@ def plot_network(wn, node_attribute=None, link_attribute=None, title=None, clb = plt.colorbar(nodes, shrink=0.5, pad=0, ax=ax) clb.ax.set_title(node_colorbar_label, fontsize=10) if add_link_colorbar and link_attribute: - vmin = min(map(abs,link_attribute.values())) - vmax = max(map(abs,link_attribute.values())) + if link_range[0] is None: + vmin = min(link_attribute.values()) + else: + vmin = link_range[0] + if link_range[1] is None: + vmax = max(link_attribute.values()) + else: + vmax = link_range[1] sm = plt.cm.ScalarMappable(cmap=link_cmap, norm=plt.Normalize(vmin=vmin, vmax=vmax)) sm.set_array([]) clb = plt.colorbar(sm, shrink=0.5, pad=0.05, ax=ax)