From 8da4b4c5f399c764bf96bda36004ebb57f05c548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Gonz=C3=A1lez?= Date: Wed, 18 Jan 2023 16:12:38 +0100 Subject: [PATCH] placing the legend --- quapy/plot.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/quapy/plot.py b/quapy/plot.py index 15c7be5..358bf45 100644 --- a/quapy/plot.py +++ b/quapy/plot.py @@ -306,9 +306,10 @@ def error_by_drift(method_names, true_prevs, estim_prevs, tr_prevs, if show_density: ax2 = ax.twinx() + densities = npoints/np.sum(npoints) ax2.bar([ind * binwidth-binwidth/2 for ind in range(len(bins))], - npoints/np.sum(npoints), alpha=0.15, color='g', width=binwidth, label='density') - ax2.set_ylim(0,1) + densities, alpha=0.15, color='g', width=binwidth, label='density') + ax2.set_ylim(0,max(densities)) ax2.spines['right'].set_color('g') ax2.tick_params(axis='y', colors='g') @@ -329,7 +330,9 @@ def error_by_drift(method_names, true_prevs, estim_prevs, tr_prevs, if show_legend: - fig.legend(bbox_to_anchor=(1.05, 1), loc="upper right") + fig.legend(loc='lower center', + bbox_to_anchor=(1, 0.5), + ncol=(len(method_names)+1)//2) _save_or_show(savepath)