From fc228a722d01c664aa1766f44651db4e5cb1e5a4 Mon Sep 17 00:00:00 2001
From: Alex Moreo <alejandro.moreo@isti.cnr.it>
Date: Tue, 6 Jul 2021 09:57:52 +0200
Subject: [PATCH] setting different colors to error drifts

---
 TweetSentQuant/experiments_NPP.py |  2 +-
 TweetSentQuant/gen_plots.py       | 10 +++++-----
 quapy/plot.py                     |  7 +++++--
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/TweetSentQuant/experiments_NPP.py b/TweetSentQuant/experiments_NPP.py
index bd9b808..d14f32c 100644
--- a/TweetSentQuant/experiments_NPP.py
+++ b/TweetSentQuant/experiments_NPP.py
@@ -74,7 +74,7 @@ def quantification_ensembles():
     # will be skipped (by setting hyperparameters to None)
     hyper_none = None
     yield 'epaccmaeptr', EPACC(newLR(), optim='mae', policy='ptr', **common), hyper_none
-    yield 'epaccmaemae1k', EPACC(newLR(), optim='mae', policy='mae', **common), hyper_none
+    yield 'epaccmaemae', EPACC(newLR(), optim='mae', policy='mae', **common), hyper_none
     # yield 'esldmaeptr', EEMQ(newLR(), optim='mae', policy='ptr', **common), hyper_none
     # yield 'esldmaemae', EEMQ(newLR(), optim='mae', policy='mae', **common), hyper_none
 
diff --git a/TweetSentQuant/gen_plots.py b/TweetSentQuant/gen_plots.py
index 360a96b..dc5a0a9 100644
--- a/TweetSentQuant/gen_plots.py
+++ b/TweetSentQuant/gen_plots.py
@@ -82,13 +82,13 @@ new_methods_ae = ['svmmae' , 'epaccmaeptr', 'epaccmaemae', 'hdy', 'quanet']
 new_methods_rae = ['svmmrae' , 'epaccmraeptr', 'epaccmraemrae', 'hdy', 'quanet']
 
 plot_error_by_drift(gao_seb_methods+new_methods_ae, error_name='ae', path=plotdir)
-plot_error_by_drift(gao_seb_methods+new_methods_rae, error_name='rae', logscale=True, path=plotdir)
+# plot_error_by_drift(gao_seb_methods+new_methods_rae, error_name='rae', logscale=True, path=plotdir)
 
-diagonal_plot(gao_seb_methods+new_methods_ae, error_name='ae', path=plotdir)
-diagonal_plot(gao_seb_methods+new_methods_rae, error_name='rae', path=plotdir)
+# diagonal_plot(gao_seb_methods+new_methods_ae, error_name='ae', path=plotdir)
+# diagonal_plot(gao_seb_methods+new_methods_rae, error_name='rae', path=plotdir)
 
-binary_bias_global(gao_seb_methods+new_methods_ae, error_name='ae', path=plotdir)
-binary_bias_global(gao_seb_methods+new_methods_rae, error_name='rae', path=plotdir)
+# binary_bias_global(gao_seb_methods+new_methods_ae, error_name='ae', path=plotdir)
+# binary_bias_global(gao_seb_methods+new_methods_rae, error_name='rae', path=plotdir)
 
 #binary_bias_bins(gao_seb_methods+new_methods_ae, error_name='ae', path=plotdir)
 #binary_bias_bins(gao_seb_methods+new_methods_rae, error_name='rae', path=plotdir)
diff --git a/quapy/plot.py b/quapy/plot.py
index 8d46ea5..d77b82a 100644
--- a/quapy/plot.py
+++ b/quapy/plot.py
@@ -208,13 +208,14 @@ def error_by_drift(method_names, true_prevs, estim_prevs, tr_prevs, n_bins=20, e
         inds = np.digitize(tr_test_drifts, bins, right=True)
         inds_histogram_global += np.histogram(tr_test_drifts, density=True, bins=bins)[0]
 
-        xs, ys, ystds = [], [], []
+        xs, ys, ystds, npoints = [], [], [], []
         for ind in range(len(bins)):
             selected = inds==ind
             if selected.sum() > 0:
                 xs.append(ind*binwidth)
                 ys.append(np.mean(method_drifts[selected]))
                 ystds.append(np.std(method_drifts[selected]))
+                npoints.append(len(method_drifts[selected]))
 
         xs = np.asarray(xs)
         ys = np.asarray(ys)
@@ -224,7 +225,9 @@ def error_by_drift(method_names, true_prevs, estim_prevs, tr_prevs, n_bins=20, e
         min_x = min_x_method if min_x is None or min_x_method < min_x else min_x
         max_x = max_x_method if max_x is None or max_x_method > max_x else max_x
 
-        ax.errorbar(xs, ys, fmt='-', marker='o', label=method, markersize=3, zorder=2)
+        p = ax.errorbar(xs, ys, fmt='-', marker='o', label=method, markersize=3, zorder=2)
+        ax.scatter(xs, ys, s=npoints, marker="h", color=p[-1].get_color())
+
         if show_std:
             ax.fill_between(xs, ys-ystds, ys+ystds, alpha=0.25)