From 3af7c70a5387d4a9a916850c6a8000c0f9669880 Mon Sep 17 00:00:00 2001 From: Alejandro Moreo Date: Tue, 4 Oct 2022 09:12:51 +0200 Subject: [PATCH] restoring the default legend in diag plot --- quapy/plot.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/quapy/plot.py b/quapy/plot.py index cdb9b1e..6491256 100644 --- a/quapy/plot.py +++ b/quapy/plot.py @@ -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} 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) - 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: true_prev = true_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) if legend: - # box = ax.get_position() - # 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.set_position([box.x0, box.y0, box.width * 0.8, box.height]) - ax.legend(loc='lower center', - bbox_to_anchor=(1, -0.5), - ncol=(len(method_names)+1)//2) + box = ax.get_position() + 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.set_position([box.x0, box.y0, box.width * 0.8, box.height]) + # ax.legend(loc='lower center', + # bbox_to_anchor=(1, -0.5), + # ncol=(len(method_names)+1)//2) _save_or_show(savepath)