Skip to content

Commit

Permalink
Merge pull request #429 from kaklise/demos
Browse files Browse the repository at this point in the history
Fixed bug in network graphic related to link colormap
  • Loading branch information
kaklise committed Jun 13, 2024
2 parents f223a3c + 2ed521b commit cd9290c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions wntr/graphics/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cd9290c

Please sign in to comment.