-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update plot_network to use the geopandas plotting API in place of the networkx plotting API #451
base: main
Are you sure you want to change the base?
Conversation
…ions for attributes
…eopandas backend to handle lists for attributes and add shapes for valves and pumps.
Pending items to be resolved here or saved for later updates:
|
Hi @meghnathomas, it seems I cannot directly add you as a reviewer to the PR. This probably has to do with some repository level restriction on who can be added as a reviewer. I'll see what I can do to get you added, but let me know if it causes any problems with the review in the meantime. |
Failing tests should be addressed when #458 is pulled in. |
Will this implementation keep geopandas as an optional dependency, only needed if plotting ? Would be much appreciated if this is the case :-) |
Hi, sorry for the delay on the review! Here's some thoughts/comments:
Similarly, these are the results from
But when we run
Am I the only one seeing these discrepancies? These are the package version I'm working with on my machine:
|
Hi @meghnathomas, thanks for your rigorous testing of the PR. I'll work through the items you pointed out and get back to you with some updates . |
…fix bugs pointed out by meghna: colorbar scale and spacing, reduce directed arrow size, add option for pumps/valves (default to not plot),
I also caught a bug where labels only rendered for junctions/pipes rather than all assets. |
@kbonney awesome, thanks, everything looks good with the colorbar values, spacing b/w plot and colorbar, arrow sizes, and suppressing pump/valve plotting! A couple of comments:
I didn't look closely enough at the figures to check if this is true for pumps (and valves) too, but this question applies to them as well |
Thanks for the additional comments @meghnathomas:
For both nodes and links, all assets should be shown unless a list or Series is passed in as the attribute. In that case, only the asset names that show up in the list or Series index will be shown. |
Summary
This PR updates the
plot_network
function by replacingnetworkx
plotting functions withgeopandas
plotting functions. This builds on the geospatial capabilities ofwntr
by using theGeoDataFrames
generated byto_gis()
to interface with thegeopandas
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:
link_attribute
andnode_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 elevatinggeopandas
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.An additional test in
test_graphics
is added to cover additional test cases. For development purposes, the oldplot_network
is included in this test file under the nameplot_network_nx
. Intest_plot_network_options
there is a variablecompare
which can be manually set to True to produce plots that side-by-side compare the old and new plotting functions. However, since we don't want to continue support the networkx plotting this isn't ran as part of the default test suite.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.