Now I am making some plots using python. When the xtick is too long, then the x label is outside of the plot. Like below:
I know we can adjust it when we save the figure by the command plt.savefig("plot_name",bbox_inches='tight'), but this will change the size of the figures if I am making several plots when I compile in the latex, like below.
I want all my plots have the same size, then when I compile in the latex, they will have the same size.
Do anyone can offer me some hint to solve this problem? Thanks a lot.
The code to make those plots are: (this posted code is not exactly the same code to make above plots, since I can not post that one. But those two pretty much the same, the only difference is that one has a for loop to make several figures, the other one enumerate all figures.)
params = {'backend': 'ps',
'font.size': 30,
'font.style': 'normal',
'axes.labelsize': 30,
#'text.fontsize': 30,
'axes.linewidth': 2,
'legend.fontsize': 12,
'xtick.labelsize': 25,
'ytick.labelsize': 25,
'text.usetex': True,
'ps.usedistiller': 'xpdf'}
rcParams.update(params)
for i in range(len(sepa_step)):
if i == len(sepa_step) - 1:
continue
if i % 3 == 0: ########### calculating average flux
stack_flux1 = stack[i] / stack_num[i]
stack_flux2 = stack[i+1] / stack_num[i+1]
stack_flux3 = stack[i+2] / stack_num[i+2]
f, (ax1, ax2, ax3) = plt.subplots(3, sharex=True, sharey=False,figsize=(10,20))
ax1.plot(wave_alpha,stack_flux1,'-b',linewidth=4)
ax1.set_ylabel(r'$10^{-17} \ {\rm erg} \ {\rm cm}^{-2} \ {\rm s}^{-1} \ {\rm \AA}^{-1}$',fontsize = 30)
ax1.tick_params('both', length=10, width=2, which='major')
ax1.tick_params('both', length=5, width=2, which='minor')
ax1.axvline(x=6562.81, linewidth=4, color='r',linestyle='--')
ax2.plot(wave_alpha,stack_flux2,'-b',linewidth=4)
ax2.set_ylabel(r'$10^{-17} \ {\rm erg} \ {\rm cm}^{-2} \ {\rm s}^{-1} \ {\rm \AA}^{-1}$',fontsize = 30)
ax2.tick_params('both', length=10, width=2, which='major')
ax2.tick_params('both', length=5, width=2, which='minor')
ax2.axvline(x=6562.81, linewidth=4, color='r',linestyle='--')
ax3.plot(wave_alpha,stack_flux3,'-b',linewidth=4)
ax3.set_ylabel(r'$10^{-17} \ {\rm erg} \ {\rm cm}^{-2} \ {\rm s}^{-1} \ {\rm \AA}^{-1}$',fontsize = 30)
ax3.set_xlabel(r'$\lambda$ ($\AA$)',fontsize = 30)
ax3.tick_params('both', length=10, width=2, which='major')
ax3.tick_params('both', length=5, width=2, which='minor')
ax3.axvline(x=6562.81, linewidth=4, color='r',linestyle='--')
title1 = 'separation ' + str(sepa_step[i]) + '$\sim$' + str(sepa_step[i+1]) + ' mpc'
title2 = 'separation ' + str(sepa_step[i+1]) + '$\sim$' + str(sepa_step[i+2]) + ' mpc'
title3 = 'separation ' + str(sepa_step[i+2]) + '$\sim$' + str(sepa_step[i+3]) + ' mpc'
ax1.set_title(title1,fontsize=20)
ax2.set_title(title2,fontsize=20)
ax3.set_title(title3,fontsize=20)
#f.subplots_adjust(hspace=0.5)
plot_name = './plots_fiton/separation_' + str(i/3 + 1) + '.eps'
#plt.subplots_adjust(left=0.25, right=0.9, top=0.95, bottom=0.05)
plt.savefig(plot_name,bbox_inches='tight')