PDFs: save all Axes as separate figures

This commit is contained in:
Eric Teunis de Boone 2023-11-14 15:29:48 +01:00
parent a32ae6b2ef
commit 770c49a646

View file

@ -93,8 +93,6 @@ if True:
amplitudes = np.linspace(0,amp_max*5,500) amplitudes = np.linspace(0,amp_max*5,500)
signals = np.linspace(0.1,signal_max*5,101) signals = np.linspace(0.1,signal_max*5,101)
if False: if False:
fig2, ax2 = plt.subplots(2,2,figsize=(2*8,2*8))
ax2 = fig2.get_axes()
V_theta = [variance(thetas,phase_distribution(thetas,sigma,s)) for s in signals ] V_theta = [variance(thetas,phase_distribution(thetas,sigma,s)) for s in signals ]
E_theta=[expectation(thetas,phase_distribution(thetas,sigma,s)) for s in signals ] E_theta=[expectation(thetas,phase_distribution(thetas,sigma,s)) for s in signals ]
V_theta_g = [variance(thetas,phase_distribution_gauss(thetas,sigma,s)) for s in signals ] V_theta_g = [variance(thetas,phase_distribution_gauss(thetas,sigma,s)) for s in signals ]
@ -104,23 +102,35 @@ if False:
V_a_g = [variance(amplitudes,amplitude_distribution_gauss(amplitudes,sigma,s)) for s in signals ] V_a_g = [variance(amplitudes,amplitude_distribution_gauss(amplitudes,sigma,s)) for s in signals ]
E_a_g=[expectation(amplitudes,amplitude_distribution_gauss(amplitudes,sigma,s)) for s in signals ] E_a_g=[expectation(amplitudes,amplitude_distribution_gauss(amplitudes,sigma,s)) for s in signals ]
fig2, _ax2 = plt.subplots(2,2,figsize=(2*8,2*8))
ax2 = fig2.get_axes()
if True:
_figs = []
_axs = []
for i, ax in enumerate(_ax2):
_f, _a = plt.subplots(1,1, figsize=(1*8, 1*8))
_figs.append(_f)
_axs.append(_a)
ax2[i] = MethodProxy(ax2[0], _a)
ax2[0].plot(signals,E_a,label='$p(a)$') ax2[0].plot(signals,E_a,label='$p(a)$')
ax2[0].plot(signals,E_a_g,ls='dashed',label='Gaussian approx.') ax2[0].plot(signals,E_a_g,ls='dashed',label='Gaussian approx.')
ax2[0].set_xscale('log') ax2[0].set_xscale('log')
ax2[0].set_yscale('log') ax2[0].set_yscale('log')
ax2[0].set_ylabel('$\mu_a$') ax2[0].set_ylabel('$\mu_a$')
ax2[1].plot(signals,V_a,label='$p(a)$') ax2[1].plot(signals,V_a,label='$p(a)$')
ax2[1].plot(signals,V_a_g,ls='dashed',label='Gaussian approx.') ax2[1].plot(signals,V_a_g,ls='dashed',label='Gaussian approx.')
ax2[1].set_xscale('log') ax2[1].set_xscale('log')
ax2[1].set_ylabel('$\sigma_a^2$') ax2[1].set_ylabel('$\sigma_a^2$')
ax2[2].plot(signals,E_theta,label=r'$p(\theta)$') ax2[2].plot(signals,E_theta,label=r'$p(\theta)$')
ax2[2].plot(signals,E_theta_g,ls='dashed',label='Gaussian approx.') ax2[2].plot(signals,E_theta_g,ls='dashed',label='Gaussian approx.')
ax2[2].set_xscale('log') ax2[2].set_xscale('log')
ax2[2].set_ylim(-1.1,1.1) ax2[2].set_ylim(-1.1,1.1)
ax2[2].set_ylabel(r'$\mu_\theta$') ax2[2].set_ylabel(r'$\mu_\theta$')
ax2[3].plot(signals,V_theta,label=r'$p(\theta)$') ax2[3].plot(signals,V_theta,label=r'$p(\theta)$')
ax2[3].plot(signals,V_theta_g,ls='dashed',label='Gaussian approx.') ax2[3].plot(signals,V_theta_g,ls='dashed',label='Gaussian approx.')
ax2[3].set_xscale('log') ax2[3].set_xscale('log')
@ -130,9 +140,18 @@ if False:
a.grid(which='both') a.grid(which='both')
a.set_xlabel(r'$s/\sigma$') a.set_xlabel(r'$s/\sigma$')
a.legend() a.legend()
fig2.tight_layout() fig2.tight_layout()
fig2.savefig('expectation_variance.pdf') fig2.savefig('expectation_variance.pdf')
for i, _f in enumerate(_figs):
fnames = [
'amplitude_mean',
'amplitude_sigma',
'phase_mean',
'phase_sigma',
][i]
_f.savefig(fnames+'.pdf')
plt.close(_f)
## figure 3, beacon timing accuracy ## figure 3, beacon timing accuracy
if True: if True: