@@ -47,7 +47,7 @@ def plot_network(wn, node_attribute=None, link_attribute=None, title=None,
47
47
node_size = 20 , node_range = [None ,None ], node_alpha = 1 , node_cmap = None , node_labels = False ,
48
48
link_width = 1 , link_range = [None ,None ], link_alpha = 1 , link_cmap = None , link_labels = False ,
49
49
add_colorbar = True , node_colorbar_label = 'Node' , link_colorbar_label = 'Link' ,
50
- directed = False , ax = None , filename = None ):
50
+ directed = False , ax = None , show_plot = True , filename = None ):
51
51
"""
52
52
Plot network graphic
53
53
@@ -127,6 +127,9 @@ def plot_network(wn, node_attribute=None, link_attribute=None, title=None,
127
127
Axes for plotting (None indicates that a new figure with a single
128
128
axes will be used)
129
129
130
+ show_plot: bool, optional
131
+ If True, show plot with plt.show()
132
+
130
133
filename : str, optional
131
134
Filename used to save the figure
132
135
@@ -246,7 +249,8 @@ def plot_network(wn, node_attribute=None, link_attribute=None, title=None,
246
249
if filename :
247
250
plt .savefig (filename )
248
251
249
- plt .show (block = False )
252
+ if show_plot is True :
253
+ plt .show (block = False )
250
254
251
255
return ax
252
256
@@ -772,7 +776,7 @@ def network_animation(wn, node_attribute=None, link_attribute=None, title=None,
772
776
ax = plot_network (wn , node_attribute = initial_node_values , link_attribute = initial_link_values , title = title_name ,
773
777
node_size = node_size , node_range = node_range , node_alpha = node_alpha , node_cmap = node_cmap , node_labels = node_labels ,
774
778
link_width = link_width , link_range = link_range , link_alpha = link_alpha , link_cmap = link_cmap , link_labels = link_labels ,
775
- add_colorbar = add_colorbar , directed = directed , ax = ax )
779
+ add_colorbar = add_colorbar , directed = directed , ax = ax , show_plot = False )
776
780
777
781
def update (n ):
778
782
if node_attribute is not None :
@@ -796,7 +800,7 @@ def update(n):
796
800
ax = plot_network (wn , node_attribute = node_values , link_attribute = link_values , title = title_name ,
797
801
node_size = node_size , node_range = node_range , node_alpha = node_alpha , node_cmap = node_cmap , node_labels = node_labels ,
798
802
link_width = link_width , link_range = link_range , link_alpha = link_alpha , link_cmap = link_cmap , link_labels = link_labels ,
799
- add_colorbar = add_colorbar , directed = directed , ax = ax )
803
+ add_colorbar = add_colorbar , directed = directed , ax = ax , show_plot = False )
800
804
801
805
return ax
802
806
0 commit comments