network_animation
does not behave as intended in Jupyter Notebooks
#389
Labels
network_animation
does not behave as intended in Jupyter Notebooks
#389
Summary
I had difficulty using
anim = wntr.graphics.network_animation(wn)
and getting the desired behavior in a Jupyter Notebook (+VS Code), i.e. something where I can replay the network results and click through the timesteps.The best way to do this would be to use
from IPython.display import HTML
and thenHTML(anim.to_jshtml())
. However, the example code below would lead to problems: instead of the desired behavior as demonstrated here, I ended up with a lot of single frames plotted below one another, and an empty interactive video frame.I figured that this is because the function
plot_network
, which is called bynetwork_animation
, plots each frame withplt.show(block=False)
.I'd suggest having an extra argument in
plot_network
, for exampleshow_plot
, set toTrue
by default, but changed toFalse
when called within thenetwork_animation
function. With this solution, also demonstrated below, everything works as expected.Example
Environment
Provide information on your computing environment.
Additional context
suggestion:
I'll be happy to create a PR for this if needed.
The text was updated successfully, but these errors were encountered: