import numpy as np from matplotlib import pyplot import smooth1d import smooth1d_plot as myplot #(0) Load datasets: np.random.seed(0) dataset_classes = smooth1d.datasets.dataset_classes[1:] pyplot.close('all') fontname = u'Times New Roman' fig = myplot.MyFigure(figsize=(9, 6), axx=np.linspace(0.06, 0.71, 3), axy=[0.60, 0.08], axw=0.28, axh=0.36, fontname=fontname, set_font=True, set_visible=False) AX = fig.AX np.random.seed(0) for i, (ax, dataset_class) in enumerate(zip(AX.flatten(), dataset_classes)): dataset = dataset_class() t, y = dataset.get_data() ### add noise: J, Q = 5, y.size sd0 = smooth1d.util.noise_for_target_rmse(y, 0.01) sd = smooth1d.util.noise_for_target_rmse(y, 0.2) yn = y + sd * np.random.randn(J, Q)
uJ = np.unique(J) uamp = np.unique(amp) h = np.array([[h0[(J == j) & (amp == a)].mean() for a in uamp] for j in uJ]) H0.append(100 * h) HH0.append(H0) ### plot: pyplot.close('all') fontname = u'Times New Roman' colors = ['b', 'g', 'r', 'c', 'k'] colors = ['0.80', '0.50', 'k'] # colors = pyplot.cm.jet(np.linspace(0,1,len(cutoffs)+2))[1:-1] fig = myplot.MyFigure(figsize=(8, 4), axx=np.linspace(0.07, 0.7, 3), axy=[0.56, 0.1], axw=0.29, axh=0.43, fontname=fontname, set_visible=True) AX = fig.AX.flatten() for i, (ax, H0) in enumerate(zip(AX, HH0)): for c, h0 in zip(colors, H0): ax.plot(uJ, h0[:, 0], 'o-', color=c, markersize=3) ax.plot(uJ, h0[:, 1], 'o--', color=c, markersize=3) ax.set_xticks(np.arange(5, 51, 10)) ax.axhline(5, color='k', ls='--') ### create legends: labels_window = ['Window = %d' % x for x in windows] labels_noise = ['Noise = 1%', 'Noise = 20%'] leg0 = myplot.dummy_legend(AX[0],