plt.figure(figsize=(10, 10))
plt.subplot(2,1,1)
means = []
plt.plot(deltas[-1,:11], 'o-', label='constant $\lambda$', lw=3 ,ms=10)
# plt.legend(fontsize='xx-large')
plt.ylabel('$\overline{\chi}$ (a.u.)', fontsize=size_axis_labels, labelpad = 10)
plt.xticks(range(11), [f'' for i in range(1,12)])
plt.yticks([0.88, 0.92, 0.96, 1.0, 1.04], fontsize=size_tick_labels)
def add_dos(ylim=None):
plt.twinx()
for i, (dos, name, ls) in enumerate(zip([dos_PBE21],
['21 Nb(110)'],
['s--']
)):
xlbl, x, xunit = dos.outputs.dos_data_interpol.get_x(); x = x[0]
ix0 = np.where(abs(x)==abs(x).min())[0][0]
ylbl, y, yunit = dos.outputs.dos_data_interpol.get_y()[0]
plt.plot(y[:len(y)//2+1,ix0][3:], ls, ms=10, lw=4, color='grey', label=name)
plt.ylabel('DOS @ $E_\mathrm{F}$ (1/eV)', fontsize=size_axis_labels, rotation=270, labelpad = 25,)
plt.yticks([1.2, 1.3, 1.4, 1.5, 1.6], fontsize=size_tick_labels)
if ylim is not None:
plt.ylim(ylim[0], ylim[1])
add_dos([1.2, 1.65])
plt.annotate(xy = (9.2, 1.465), xytext=(8.2, 1.465), arrowprops=dict(arrowstyle="->, head_width=0.5", lw=4, color='grey', ), text='')
plt.annotate(xy = (2.5, 1.57), xytext=(1.5, 1.57), arrowprops=dict(arrowstyle="<-, head_width=0.5", color='C0', lw=4, ), text='')
plt.subplot(2,1,2)
plt.plot(deltas[-1,:11], '^-', label='unrelaxed ($\lambda=1.21\,\mathrm{eV}$)', lw=3 ,ms=10)
means.append(np.mean(deltas[-1,:11]))
# plt.axhline(means[-1], lw=3 ,ls='-', color='C0')
# variable lambda
plt.plot(deltas2[-1,:11], 's--' , label='unrelaxed, variable $\lambda$ ($\lambda_0=1.15\,\mathrm{eV}$)', lw=3 ,ms=10)
means.append(np.mean(deltas[-1,:11]))
# plt.axhline(means[-1], lw=3 ,ls='--', color='C1')
# relaxed
plt.plot(deltas3[-1,:11], 'o-' , label='relaxed ($\lambda=1.23\,\mathrm{eV}$)', lw=3 ,ms=10)
means.append(np.mean(deltas[-1,:11]))
# plt.axhline(means[-1], lw=3 ,ls='--', color='C2')
#1.15309583424 1.2085712351999998 1.1095080191999995 1.2269771807327998
# bulk
plt.axhline(0.98945, ls=':', lw=3, color='grey', label='bulk ($\lambda=1.11\,\mathrm{eV}$)') # bulk lambda
plt.ylabel('$\overline{\chi}$ (a.u.)', fontsize=size_axis_labels, labelpad = 10)
plt.legend(fontsize=size_legend)
plt.ylim(0.7, 1.9)
plt.xticks(range(11), [f'{i}' for i in range(1,12)], fontsize=size_tick_labels)
plt.yticks([0.8, 1.0, 1.2, 1.4, 1.6, 1.8], fontsize=size_tick_labels)
plt.xlabel('layer index', fontsize=size_axis_labels, labelpad = 12)
plt.tight_layout()
plt.subplots_adjust(hspace=0.05, )
plt.annotate(xycoords='figure fraction', xy = (0.11, 0.01), text='surface', fontsize=size_tick_labels, weight="bold")
plt.annotate(xycoords='figure fraction', xy = (0.82, 0.01), text='center', fontsize=size_tick_labels, weight="bold")
plt.annotate(xycoords='figure fraction', xy = (0.005, 0.97), text='(a)', fontsize=size_plabel, weight="bold")
plt.annotate(xycoords='figure fraction', xy = (0.005, 0.5), text='(b)', fontsize=size_plabel, weight="bold")
plt.savefig('Fig5.png', dpi=150)
plt.savefig('Fig5.pdf')
plt.show()