def load_and_plot(ax, L, t_perp, filling, extrap_type, extrap_pars, c, m, label):
# load fit
fname = data_path + '/energy_extrap_{extrap_type}_fit_{pars}_L={L}_n={fill}_tperp={tperp}.txt'.format(extrap_type=extrap_type, pars=extrap_pars, L=L, fill=filling, tperp=t_perp)
if not path.exists(fname):
print '# data n={} t_perp={} not found.'.format(filling, t_perp)
return
d = np.loadtxt(fname)
ax.plot(d[:,0], d[:,1], '-'+c)
# load data
fname = data_path + '/energy_extrap_{extrap_type}_L={L}_n={fill}_tperp={tperp}.txt'.format(extrap_type=extrap_type, L=L, fill=filling, tperp=t_perp)
if not path.exists(fname):
print '# data n={} t_perp={} not found.'.format(filling, t_perp)
return
d = np.loadtxt(fname)
ax.plot(d[:,0], d[:,1], c+m, label=label)
def plot_all_extraps(L, t_perp, filling):
figure(figsize=(10,6))
ax = subplot(111)
load_and_plot(ax, L, t_perp, filling, extrap_type='variance', extrap_pars='deg1', c='b', m='o', label='Variance')
ax.set_xlim(xmin=0)
ax.set_xticks([])
lns1, lab1 = ax.get_legend_handles_labels()
ax = ax.twiny()
load_and_plot(ax, L, t_perp, filling, extrap_type='bonddim', extrap_pars='deg2', c='g', m='>', label='1 / M')
ax.set_xlim(xmin=0)
ax.set_xticks([])
lns2, lab2 = ax.get_legend_handles_labels()
ax = ax.twiny()
load_and_plot(ax, L, t_perp, filling, extrap_type='truncation', extrap_pars='deg1', c='r', m='v', label='Truncation')
ax.set_xlim(xmin=0)
ax.set_xticks([])
lns3, lab3 = ax.get_legend_handles_labels()
lns = lns1 + lns2 + lns3
lab = lab1 + lab2 + lab3
plt.legend(lns, lab, loc='best')