def load_and_plot(ax, L, t_perp, filling, bname, all_x, varname, xtransform, ytransform, fit_color, marker_color):
markers = ['o', '>', 's']
for i,site_x in enumerate(all_x):
# load fit
fname = data_path + '/{bname}_fit_{pars}_L={L}_n={fill}_tperp={tperp}_x={x}.txt'.format(bname=bname, pars=extrap_pars, L=L, x=site_x, fill=filling, tperp=t_perp)
if not path.exists(fname):
print '# data n={} t_perp={} not found.'.format(filling, t_perp), fname
return
d = np.loadtxt(fname)
fit_res = load_fit_data(fname)
sel = np.ones(len(d), dtype=bool)
if 'fit_cut' in fit_res:
fit_cut = float(fit_res['fit_cut'])
sel = d[:,0] <= fit_cut
ax.plot(xtransform(d[sel,0]), ytransform(d[sel,1]), '-', c=fit_color)
ax.plot(xtransform(d[-sel,0]), ytransform(d[-sel,1]), '--', c=fit_color)
# load data
fname = data_path + '/{bname}_L={L}_n={fill}_tperp={tperp}_x={x}.txt'.format(bname=bname, L=L, x=site_x, fill=filling, tperp=t_perp)
if not path.exists(fname):
print '# data n={} t_perp={} not found.'.format(filling, t_perp), fname
return
d = np.loadtxt(fname)
ax.plot(xtransform(d[:,0]), ytransform(d[:,2]), markers[i], color=marker_color, mec=marker_color, mfc='w', label='$%s=%.0f$'% (varname, site_x))
def make_plot(L, t_perp, filling, what, all_x, varname):
figure(figsize=(10,6))
subplots_adjust(left=0.25, right=0.95, top=0.95, hspace=0.1, wspace=0.05)
ax1 = subplot(121)
load_and_plot(ax1, L, t_perp, filling, what+'_extrap_bonddim', all_x, varname, transform.scale(invm_scale), transform.ident(),
fit_color='g', marker_color='r')
legend(loc='best')
ax1.set_xlabel('1000/M')
xlim = ax1.get_xlim()
ax1.set_xlim(xmin=xlim[1], xmax=0.)
ax2 = subplot(122)
load_and_plot(ax2, L, t_perp, filling, what+'_extrap_variance', all_x, varname, transform.ident(), transform.ident(),
fit_color='b', marker_color='y')
ax2.set_xlim(xmin=0)
ax2.set_xlabel('Var[H]')
ax3 = twiny(ax2)
load_and_plot(ax3, L, t_perp, filling, what+'_extrap_truncation', all_x, varname, transform.ident(), transform.ident(),
fit_color='k', marker_color='c')
ax3.set_xlim(xmin=0)
ax3.set_xlabel('Truncated Weight')
ax2.yaxis.set_major_formatter(NullFormatter())