python - x position of matplotlib -


now making plots using python. when xtick long, x label outside of plot. below: enter image description here

i know can adjust when save figure command plt.savefig("plot_name",bbox_inches='tight'), change size of figures if making several plots when compile in latex, below.

enter image description here

i want plots have same size, when compile in latex, have same size.

do can offer me hint solve problem? lot.

the code make plots are: (this posted code not same code make above plots, since can not post one. 2 pretty same, difference 1 has loop make several figures, other 1 enumerate 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 in range(len(sepa_step)): if == len(sepa_step) - 1:     continue if % 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') 

you can adjust plot parameters in matplotlibrc file including size of margins. file typically in ~/.config/matplotlib/matplotlibrc on linux. file not created default, suggest copying template , modifying it.

you can interested in following settings:

# figure subplot parameters.  dimensions fraction of # figure width or height figure.subplot.left    : 0.125  # left side of subplots of figure figure.subplot.right   : 0.9    # right side of subplots of figure figure.subplot.bottom  : 0.1    # bottom of subplots of figure figure.subplot.top     : 0.9    # top of subplots of figure figure.subplot.wspace  : 0.2    # amount of width reserved blank space between subplots figure.subplot.hspace  : 0.2    # amount of height reserved white space between subplots 

which determine how space left around plot.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -

html - jQuery UI Sortable - Remove placeholder after item is dropped -