diff --git a/quapy/plot.py b/quapy/plot.py index c1a857e..7b2145f 100644 --- a/quapy/plot.py +++ b/quapy/plot.py @@ -4,6 +4,7 @@ from matplotlib.cm import get_cmap import numpy as np from matplotlib import cm from scipy.stats import ttest_ind_from_stats +from matplotlib.ticker import StrMethodFormatter, NullFormatter import quapy as qp @@ -256,6 +257,9 @@ def error_by_drift(method_names, true_prevs, estim_prevs, tr_prevs, # x_error function) and 'y' is the estim-test shift (computed as according to y_error) data = _join_data_by_drift(method_names, true_prevs, estim_prevs, tr_prevs, x_error, y_error, method_order) + if method_order is None: + method_order = method_names + _set_colors(ax, n_methods=len(method_order)) bins = np.linspace(0, 1, n_bins+1) @@ -266,7 +270,11 @@ def error_by_drift(method_names, true_prevs, estim_prevs, tr_prevs, tr_test_drifts = data[method]['x'] method_drifts = data[method]['y'] if logscale: - method_drifts=np.log(1+method_drifts) + #method_drifts=np.log(1+method_drifts) + plt.yscale("log") + ax.yaxis.set_major_formatter(StrMethodFormatter('{x:.2f}')) + ax.yaxis.set_minor_formatter(StrMethodFormatter('{x:.2f}')) + inds = np.digitize(tr_test_drifts, bins, right=True) @@ -299,7 +307,7 @@ def error_by_drift(method_names, true_prevs, estim_prevs, tr_prevs, if show_density: ax.bar([ind * binwidth-binwidth/2 for ind in range(len(bins))], max_y*npoints/np.max(npoints), alpha=0.15, color='g', width=binwidth, label='density') - + ax.set(xlabel=f'Distribution shift between training set and test sample', ylabel=f'{error_name.upper()} (true distribution, predicted distribution)', title=title)