@@ -823,15 +823,19 @@ def plot_partition(g,part,title,fname='figure',nod_labels = None, pos = None,
823
823
"""This function takes in a graph and a partition and makes a figure that
824
824
has each node labeled according to its partition assignment"""
825
825
826
+
827
+ write_labels = False
826
828
nnod = g .number_of_nodes ()
827
829
828
830
if nod_labels == None :
829
831
nod_labels = dict (zip (range (nnod ),range (nnod )))
830
832
else :
831
833
nod_labels = dict (zip (range (nnod ),nod_labels ))
832
834
833
- #nod_labels = array_to_string(nod_labels)
834
835
836
+ plt .figure ()
837
+ plt .subplot (111 )
838
+ plt .axis ('off' )
835
839
836
840
if pos == None :
837
841
pos = nx .circular_layout (g )
@@ -854,7 +858,7 @@ def plot_partition(g,part,title,fname='figure',nod_labels = None, pos = None,
854
858
for v in val :
855
859
if les_dam != 'none' :
856
860
plt .scatter (pos [v ][0 ],pos [v ][1 ],s = 500 * les_dam [v ],c = 'orange' ,marker = (10 ,1 ,0 ))
857
-
861
+
858
862
if within_mod [v ] > 1 :
859
863
nx .draw_networkx_nodes (g ,pos ,nodelist = [v ],node_color = col [niter ],node_size = part_coeff [v ] * 500 + 50 ,node_shape = 's' ,linewidths = 2 )
860
864
else :
@@ -871,7 +875,7 @@ def plot_partition(g,part,title,fname='figure',nod_labels = None, pos = None,
871
875
for v in val :
872
876
if les_dam != 'none' :
873
877
plt .scatter (pos [v ][0 ],pos [v ][1 ],s = 500 * les_dam [v ],c = 'orange' ,marker = (10 ,1 ,0 ))
874
-
878
+
875
879
if within_mod [v ] > 1 :
876
880
nx .draw_networkx_nodes (g ,pos ,nodelist = [v ],node_color = col2 [niter ],node_size = part_coeff [v ] * 500 + 50 ,node_shape = 's' ,linewidths = 2 )
877
881
else :
@@ -902,11 +906,20 @@ def plot_partition(g,part,title,fname='figure',nod_labels = None, pos = None,
902
906
else :
903
907
nx .draw_networkx_edges (g ,pos ,edgelist = edge_list_within ,edge_color = col2 [niter ])
904
908
niter += 1
905
-
906
- nx . draw_networkx_labels ( g , pos , nod_labels , font_size = 6 )
909
+
910
+
907
911
#nx.draw_networkx_edges(g,pos,edgelist=nx.edges(g))
908
912
nx .draw_networkx_edges (g ,pos ,edgelist = edge_list_between ,edge_color = 'k' )
909
-
913
+ if write_labels :
914
+ nx .draw_networkx_labels (g ,pos ,nod_labels ,font_size = 6 )
915
+
916
+ #add loop for damage labels
917
+ if les_dam != 'none' :
918
+ for m ,val in part .iteritems ():
919
+ for v in val :
920
+ if les_dam [v ] > 0 :
921
+ plt .scatter (pos [v ][0 ],pos [v ][1 ],s = 500 * les_dam [v ]+ 100 ,c = 'orange' ,marker = (4 ,1 ,0 ))
922
+
910
923
plt .title (title )
911
924
#plt.savefig(fname)
912
925
#plt.close()
0 commit comments