restoring the default legend in diag plot

This commit is contained in:
Alejandro Moreo Fernandez 2022-10-04 09:12:51 +02:00
parent 6a5c528154
commit 3af7c70a53
1 changed files with 9 additions and 9 deletions

View File

@ -49,9 +49,9 @@ def binary_diagonal(method_names, true_prevs, estim_prevs, pos_class=1, title=No
table = {method_name:[true_prev, estim_prev] for method_name, true_prev, estim_prev in order} table = {method_name:[true_prev, estim_prev] for method_name, true_prev, estim_prev in order}
order = [(method_name, *table[method_name]) for method_name in method_order] order = [(method_name, *table[method_name]) for method_name in method_order]
cm = plt.get_cmap('tab20') cm = plt.get_cmap('tab10')
NUM_COLORS = len(method_names) NUM_COLORS = len(method_names)
ax.set_prop_cycle(color=[cm(1. * i / NUM_COLORS) for i in range(NUM_COLORS)]) # ax.set_prop_cycle(color=[cm(1. * i / NUM_COLORS) for i in range(NUM_COLORS)])
for method, true_prev, estim_prev in order: for method, true_prev, estim_prev in order:
true_prev = true_prev[:,pos_class] true_prev = true_prev[:,pos_class]
estim_prev = estim_prev[:,pos_class] estim_prev = estim_prev[:,pos_class]
@ -74,13 +74,13 @@ def binary_diagonal(method_names, true_prevs, estim_prevs, pos_class=1, title=No
ax.set_xlim(0, 1) ax.set_xlim(0, 1)
if legend: if legend:
# box = ax.get_position() box = ax.get_position()
# ax.set_position([box.x0, box.y0, box.width * 0.8, box.height]) ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
# ax.legend(loc='center left', bbox_to_anchor=(1, 0.5)) ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
# ax.set_position([box.x0, box.y0, box.width * 0.8, box.height]) ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
ax.legend(loc='lower center', # ax.legend(loc='lower center',
bbox_to_anchor=(1, -0.5), # bbox_to_anchor=(1, -0.5),
ncol=(len(method_names)+1)//2) # ncol=(len(method_names)+1)//2)
_save_or_show(savepath) _save_or_show(savepath)