@@ -111,13 +111,13 @@ def main():
111111 "precision" : precision_list ,
112112 "recall" : recall_list ,
113113 "pr" : pr_auc_list ,
114- "method" : ["One-Hop GO Degree " , "Hypergeometric" , "Degree" , "RW" ],
114+ "method" : ["One-Hop GO Overlap " , "Hypergeometric" , "Degree" , "RW" ],
115115 }
116116 final_category_data [species ].append (species_data )
117117
118118 # Create a figure with 2 subplots (one for each species)
119119 fig , axes = plt .subplots (
120- 2 , 3 , figsize = (18 , 10 )
120+ 1 , 5 , figsize = (20 , 6 )
121121 ) # Create a 2x3 grid of subplots
122122 axes = axes .flatten ()
123123 colors = ["red" , "green" , "blue" , "orange" , "purple" ]
@@ -137,19 +137,22 @@ def main():
137137
138138 ax .set_xlim ([0.0 , 1.0 ])
139139 ax .set_ylim ([0.0 , 1.05 ])
140- ax .set_xlabel ("False Positive Rate" )
141- ax .set_ylabel ("True Positive Rate" )
142- ax .set_title (f"{ species_title [idx ].capitalize ()} " )
143- ax .legend (loc = "lower right" )
140+ ax .set_xlabel ("False Positive Rate" , fontsize = 14 )
141+ ax .set_ylabel ("True Positive Rate" , fontsize = 14 )
142+ ax .set_title (f"{ species_title [idx ].capitalize ()} " , fontsize = 14 )
143+ ax .legend (loc = "upper center" , bbox_to_anchor = ( 0.5 , - 0.17 ), fontsize = 12 )
144144
145- axes [5 ].set_visible (False )
145+ # axes[5].set_visible(False)
146146 fig .suptitle ("ROC Curve for All Species w/ " + subplot_titles [k ], fontsize = 20 )
147+ # Adjust layout to prevent overlap
148+ plt .tight_layout (rect = [0 , 0.05 , 1 , 0.95 ]) # Adjust rect to accommodate legends
149+ # Adjust the space between subplots
150+ plt .subplots_adjust (wspace = 0.2 )
147151 plt .savefig (Path ("./results/images/" , f"roc_{ subplot_titles [k ].lower ().replace (" " , "_" )} " ))
148- plt .tight_layout ()
149152 plt .show ()
150153
151154 fig , axes = plt .subplots (
152- 2 , 3 , figsize = (18 , 10 )
155+ 1 , 5 , figsize = (20 , 6 )
153156 ) # Create a 2x3 grid of subplots
154157 axes = axes .flatten ()
155158 colors = ["red" , "green" , "blue" , "orange" , "purple" ]
@@ -169,17 +172,20 @@ def main():
169172
170173 ax .set_xlim ([0.0 , 1.0 ])
171174 ax .set_ylim ([0.0 , 1.05 ])
172- ax .set_xlabel ("Recall" )
173- ax .set_ylabel ("Precision" )
174- ax .set_title (f"{ species_title [idx ].capitalize ()} " )
175- ax .legend (loc = "lower right" )
175+ ax .set_xlabel ("Recall" , fontsize = 14 )
176+ ax .set_ylabel ("Precision" , fontsize = 14 )
177+ ax .set_title (f"{ species_title [idx ].capitalize ()} " , fontsize = 14 )
178+ ax .legend (loc = "upper center" , bbox_to_anchor = ( 0.5 , - 0.17 ), fontsize = 12 )
176179
177- axes [5 ].set_visible (False )
180+ # axes[5].set_visible(False)
178181 fig .suptitle (
179182 "Precision/Recall Curve for All Species w/ " + subplot_titles [k ],
180183 fontsize = 20 ,
181184 )
182- plt .tight_layout ()
185+ # Adjust layout to prevent overlap
186+ plt .tight_layout (rect = [0 , 0.05 , 1 , 0.95 ]) # Adjust rect to accommodate legends
187+ # Adjust the space between subplots
188+ plt .subplots_adjust (wspace = 0.2 )
183189 plt .savefig (Path ("./results/images/" , f"pr_{ subplot_titles [k ].lower ().replace (" " , "_" )} " ))
184190 plt .show ()
185191 k += 1
@@ -236,7 +242,7 @@ def main():
236242 final_rw_data [species ][idx ]["tpr" ],
237243 color = colors [i ],
238244 lw = 2 ,
239- label = f"{ species_title [i ]} (area = %0.2f)" % final_rw_data [species ][0 ]["roc" ],
245+ label = f"{ species_title [i ]} (area = %0.2f)" % final_rw_data [species ][idx ]["roc" ],
240246 )
241247
242248 ax .set_xlim ([0.0 , 1.0 ])
@@ -269,7 +275,7 @@ def main():
269275 final_rw_data [species ][idx ]["precision" ],
270276 color = colors [i ],
271277 lw = 2 ,
272- label = f"{ species_title [i ]} (area = %0.2f)" % final_rw_data [species ][0 ]["pr" ],
278+ label = f"{ species_title [i ]} (area = %0.2f)" % final_rw_data [species ][idx ]["pr" ],
273279 )
274280
275281 ax .set_xlim ([0.0 , 1.0 ])
0 commit comments