WNTR icon indicating copy to clipboard operation
WNTR copied to clipboard

Update plot_network to use the geopandas plotting API in place of the networkx plotting API

Open kbonney opened this issue 5 months ago • 1 comments

Summary

This PR updates the plot_network function by replacing networkx plotting functions with geopandas plotting functions. This builds on the geospatial capabilities of wntr by using the GeoDataFrames generated by to_gis() to interface with the geopandas plotting capabilities. This update reduces the complexity of the plotting code, making it easier to maintain and opening opportunities for other plotting options.

These updates aim to minimize changes to the output of plot_network, except where changes add functionality. The arguments of plot_network remain unchanged, with the exception of some additional keyword arguments with defaults, so these updates should be fully backwards compatible.

New functionality includes:

  • Vertices of links are incorporated in the plot, rather than always having straight lines between junctions.
  • Valves, pumps, tanks and reservoirs are marked with distinct symbols. Direction of pumps is indicated by an arrow. (in-progress)
  • link_attribute and node_attribute string options are expanded to include attributes for all assets (pipe, valve, and pump for link and junction, tank, and reservoir for node)

Note that relying on geopandas for plotting will require elevating geopandas from an optional dependency to a required one.

This PR addresses #223 since geopandas plots the vertices, which means #390 is no longer necessary.

Tests and documentation

Current tests and documentation already cover the plot_network function.

Acknowledgement

By contributing to this software project, I acknowledge that I have reviewed the software quality assurance guidelines and that my contributions are submitted under the Revised BSD License.

kbonney avatar Oct 01 '24 21:10 kbonney