1
0
Fork 0

changes to plots again

This commit is contained in:
Pablo González 2023-01-18 14:53:46 +01:00
parent 50d886bffe
commit f10a3139d9
1 changed files with 15 additions and 9 deletions

View File

@ -4,7 +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
from matplotlib.ticker import ScalarFormatter
import quapy as qp
@ -270,11 +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)
plt.yscale("log")
ax.yaxis.set_major_formatter(StrMethodFormatter('{x:.2f}'))
ax.yaxis.set_minor_formatter(StrMethodFormatter('{x:.2f}'))
ax.set_yscale("log")
ax.yaxis.set_major_formatter(ScalarFormatter())
ax.yaxis.set_minor_formatter(ScalarFormatter())
ax.yaxis.get_major_formatter().set_scientific(False)
ax.yaxis.get_minor_formatter().set_scientific(False)
inds = np.digitize(tr_test_drifts, bins, right=True)
@ -305,8 +305,14 @@ def error_by_drift(method_names, true_prevs, estim_prevs, tr_prevs,
ax.fill_between(xs, ys-ystds, ys+ystds, alpha=0.25)
if show_density:
ax.bar([ind * binwidth-binwidth/2 for ind in range(len(bins))],
ax2 = ax.twinx()
ax2.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')
#ax2.set_ylabel("bar data")
ax2.set_ylim(0,1)
ax2.spines['right'].set_color('g')
ax2.tick_params(axis='y', colors='g')
#ax2.yaxis.set_visible(False)
ax.set(xlabel=f'Distribution shift between training set and test sample',
ylabel=f'{error_name.upper()} (true distribution, predicted distribution)',
@ -321,8 +327,8 @@ def error_by_drift(method_names, true_prevs, estim_prevs, tr_prevs,
ax.set_xlim(min_x, max_x)
if show_legend:
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
fig.legend(loc='right')
_save_or_show(savepath)