def stellarHaloMFRatio(path, database, redshifts, output_folder, outfile, xmin=10.0, xmax=14.4, ymin=-3, ymax=-1, nbins=15, h=0.7): ''' Plots stellar to dark matter halo mass ratios as a function of redshift. ''' #get Behroozi et al. fits BFits = g.glob( '/Users/niemi/Dropbox/Research/Observations/behroozi/results/*.dat') #get a colour scheme cols = pt.give_colours() #scale the SAM's output masses with this factor multiply = 1e9 #make the figure and axes instance fig = P.figure() ax = fig.add_subplot(111) #plot the different redshifts for ii, redshift in enumerate(redshifts): #get redshift, add 0.1 so that int/floor returns the closest int tmp = redshift.split() rd = int(float(tmp[2]) + 0.1) #generate the SQL query query = '''select mstar_disk, mbulge, mhalo from galpropz where ''' + redshift query += ' and mstar_disk >= 0.0 and mbulge >= 0.0' query += ' and mstar_disk + mbulge > 0.0' query += ' and gal_id = 1' #load Behroozi et al fit data BF = N.loadtxt(BFits[ii + 1]) ax.plot( BF[:, 0], # - N.log10(h), BF[:, 1], color=cols[ii], ls='--', label='Behroozi et al.: $z \sim %s$' % (BFits[ii + 1].split('z')[2][:4])) logging.debug(BFits[ii + 1]) #get data from the SQLite3 db dat = db.sqlite.get_data_sqlite(path, database, query) #rename data and calculate the ratio mstar = dat[:, 0] + dat[:, 1] mhalo = dat[:, 2] ratio = N.log10(mstar / mhalo) mhalo = N.log10(mhalo * multiply) #print ratio, N.min(ratio), N.max(ratio) #debug output ngal = len(mstar) logging.debug('%i galaxies found at z = %i\n' % (ngal, rd)) #bin the data xbin_mid, y50, y16, y84 = dm.percentile_bins(mhalo, ratio, xmin, xmax, nxbins=nbins) msk = y50 > -10 #plot the binned data # ax.errorbar(xbin_mid[msk], # y50[msk], # yerr = [y50[msk]-y16[msk], y84[msk]-y50[msk]], # color = cols[ii], # label = 'Bolshoi+SAM: $z \sim %i$' % rd) ax.plot(xbin_mid[msk], y50[msk], color=cols[ii], ms='o', ls='-', label='Bolshoi+SAM: $z \sim %i$' % rd) #set axes scales and labels ax.set_xlim(xmin, xmax) ax.set_ylim(ymin, ymax) ax.set_xlabel( r'$\log_{10} \left ( M_{\mathrm{dm}} \ [\mathrm{M}_{\odot}] \right )$') ax.set_ylabel( r'$\log_{10} \left (\frac{M_{\star}}{M_{\mathrm{dm}}} \right )$') #set small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5.) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5.) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) P.legend(shadow=True, fancybox=True, numpoints=1) P.savefig(output_folder + outfile + '.pdf') P.close()
def stellarHaloMFRatioMultiPanel(path, database, redshifts, output_folder, outfile, xmin=10.0, xmax=14.4, ymin=-3, ymax=-1, nbins=15): ''' Plots stellar to dark matter halo mass ratios as a function of redshift. ''' #get Behroozi et al. fits BFits = g.glob(hm + '/Dropbox/Research/Observations/behroozi/results/*.dat') #get a colour scheme cols = pt.give_colours() #scale the SAM's output masses with this factor multiply = 1e9 #make the figure and axes instance fig = P.figure() P.subplots_adjust(left=0.13, bottom=0.1, wspace=0.0, hspace=0.0) #plot the different redshifts for ii, redshift in enumerate(redshifts): #get redshift, add 0.1 so that int/floor returns the closest int tmp = redshift.split() rd = int(float(tmp[2]) + 0.1) #generate the SQL query query = '''select mstar_disk, mbulge, mhalo from galpropz where ''' + redshift query += ' and mstar_disk >= 0.0 and mbulge >= 0.0' query += ' and mstar_disk + mbulge > 0.0' query += ' and gal_id = 1' if ii < 6: ax = fig.add_subplot(2, 3, ii + 1) #get data from the SQLite3 db dat = db.sqlite.get_data_sqlite(path, database, query) #rename data and calculate the ratio mstar = dat[:, 0] + dat[:, 1] mhalo = dat[:, 2] ratio = N.log10(mstar / mhalo) mhalo = N.log10(mhalo * multiply) #print ratio, N.min(ratio), N.max(ratio) #debug output ngal = len(mstar) logging.debug('%i galaxies found at z = %i\n' % (ngal, rd)) #bin the data xbin_mid, y50, y16, y84 = dm.percentile_bins(mhalo, ratio, xmin, xmax, nxbins=nbins) msk = y50 > -10 #plot the binned data if ii == 6: ax.plot(xbin_mid[msk], y50[msk], 'k--', label='Bolshoi+SAM') else: ax.errorbar(xbin_mid[msk], y50[msk], yerr=[y50[msk] - y16[msk], y84[msk] - y50[msk]], color='k', label='Bolshoi+SAM') #load Behroozi et al fit data BF = N.loadtxt(BFits[ii + 1]) #plot Behroozi data if ii == 6: ax.plot(BF[:, 0], BF[:, 1], color='r', ls='--', label='Behroozi et al.') else: ax.plot(BF[:, 0], BF[:, 1], color='r', ls='-', label='Behroozi et al.') #output some information logging.debug(BFits[ii + 1]) #mark the redshift if ii < 5: P.text(0.5, 0.93, r'$ z \sim %.1f $' % (rd), horizontalalignment='center', verticalalignment='center', transform=ax.transAxes, fontsize=12) elif ii == 5: P.text(0.5, 0.93, r'$z \sim %.1f (s)\ \& \ %.1f (d)$' % (rd, rd + 1), horizontalalignment='center', verticalalignment='center', transform=ax.transAxes, fontsize=12) #set axes scales and labels ax.set_xlim(xmin - 0.1, xmax) ax.set_ylim(ymin, ymax) #set small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5.) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5.) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) #set legend if ii == 4: ax.legend(shadow=True, fancybox=True, numpoints=1, loc='lower right') #set ylabel if ii == 0 or ii == 3: ax.set_ylabel( r'$\log_{10} \left (\frac{M_{\star}}{M_{\mathrm{dm}}} \right )$' ) #set xlabel if ii == 4: # or ii == 3 or ii == 5: ax.set_xlabel( r'$\log_{10} \left ( M_{\mathrm{dm}} \ [\mathrm{M}_{\odot}] \right )$' ) #remove some y ticks if ii == 0 or ii == 3: ax.set_yticks(ax.get_yticks()[:-1]) else: ax.set_yticklabels([]) #remove some x ticks if ii == 3 or ii == 4 or ii == 5: #ax.set_xticks(ax.get_xticks()[:-1]) continue elif ii == 6: continue else: ax.set_xticklabels([]) P.savefig(output_folder + outfile + 'Multi.pdf') P.close()
def stellarHaloMFRatio(path, database, redshifts, output_folder, outfile, xmin=10.0, xmax=14.4, ymin=-3, ymax=-1, nbins=15, h=0.7): ''' Plots stellar to dark matter halo mass ratios as a function of redshift. ''' #get Behroozi et al. fits BFits = g.glob('/Users/niemi/Dropbox/Research/Observations/behroozi/results/*.dat') #get a colour scheme cols = pt.give_colours() #scale the SAM's output masses with this factor multiply = 1e9 #make the figure and axes instance fig = P.figure() ax = fig.add_subplot(111) #plot the different redshifts for ii, redshift in enumerate(redshifts): #get redshift, add 0.1 so that int/floor returns the closest int tmp = redshift.split() rd = int(float(tmp[2]) + 0.1) #generate the SQL query query = '''select mstar_disk, mbulge, mhalo from galpropz where ''' + redshift query += ' and mstar_disk >= 0.0 and mbulge >= 0.0' query += ' and mstar_disk + mbulge > 0.0' query += ' and gal_id = 1' #load Behroozi et al fit data BF = N.loadtxt(BFits[ii + 1]) ax.plot(BF[:, 0], # - N.log10(h), BF[:, 1], color=cols[ii], ls='--', label='Behroozi et al.: $z \sim %s$' % (BFits[ii + 1].split('z')[2][:4])) logging.debug(BFits[ii + 1]) #get data from the SQLite3 db dat = db.sqlite.get_data_sqlite(path, database, query) #rename data and calculate the ratio mstar = dat[:, 0] + dat[:, 1] mhalo = dat[:, 2] ratio = N.log10(mstar / mhalo) mhalo = N.log10(mhalo * multiply) #print ratio, N.min(ratio), N.max(ratio) #debug output ngal = len(mstar) logging.debug('%i galaxies found at z = %i\n' % (ngal, rd)) #bin the data xbin_mid, y50, y16, y84 = dm.percentile_bins(mhalo, ratio, xmin, xmax, nxbins=nbins) msk = y50 > -10 #plot the binned data # ax.errorbar(xbin_mid[msk], # y50[msk], # yerr = [y50[msk]-y16[msk], y84[msk]-y50[msk]], # color = cols[ii], # label = 'Bolshoi+SAM: $z \sim %i$' % rd) ax.plot(xbin_mid[msk], y50[msk], color=cols[ii], ms='o', ls='-', label='Bolshoi+SAM: $z \sim %i$' % rd) #set axes scales and labels ax.set_xlim(xmin, xmax) ax.set_ylim(ymin, ymax) ax.set_xlabel(r'$\log_{10} \left ( M_{\mathrm{dm}} \ [\mathrm{M}_{\odot}] \right )$') ax.set_ylabel(r'$\log_{10} \left (\frac{M_{\star}}{M_{\mathrm{dm}}} \right )$') #set small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5.) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5.) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) P.legend(shadow=True, fancybox=True, numpoints=1) P.savefig(output_folder + outfile + '.pdf') P.close()
def stellarHaloMFRatioMultiPanel(path, database, redshifts, output_folder, outfile, xmin=10.0, xmax=14.4, ymin=-3, ymax=-1, nbins=15): ''' Plots stellar to dark matter halo mass ratios as a function of redshift. ''' #get Behroozi et al. fits BFits = g.glob(hm + '/Dropbox/Research/Observations/behroozi/results/*.dat') #get a colour scheme cols = pt.give_colours() #scale the SAM's output masses with this factor multiply = 1e9 #make the figure and axes instance fig = P.figure() P.subplots_adjust(left=0.13, bottom=0.1, wspace=0.0, hspace=0.0) #plot the different redshifts for ii, redshift in enumerate(redshifts): #get redshift, add 0.1 so that int/floor returns the closest int tmp = redshift.split() rd = int(float(tmp[2]) + 0.1) #generate the SQL query query = '''select mstar_disk, mbulge, mhalo from galpropz where ''' + redshift query += ' and mstar_disk >= 0.0 and mbulge >= 0.0' query += ' and mstar_disk + mbulge > 0.0' query += ' and gal_id = 1' if ii < 6: ax = fig.add_subplot(2, 3, ii + 1) #get data from the SQLite3 db dat = db.sqlite.get_data_sqlite(path, database, query) #rename data and calculate the ratio mstar = dat[:, 0] + dat[:, 1] mhalo = dat[:, 2] ratio = N.log10(mstar / mhalo) mhalo = N.log10(mhalo * multiply) #print ratio, N.min(ratio), N.max(ratio) #debug output ngal = len(mstar) logging.debug('%i galaxies found at z = %i\n' % (ngal, rd)) #bin the data xbin_mid, y50, y16, y84 = dm.percentile_bins(mhalo, ratio, xmin, xmax, nxbins=nbins) msk = y50 > -10 #plot the binned data if ii == 6: ax.plot(xbin_mid[msk], y50[msk], 'k--', label='Bolshoi+SAM') else: ax.errorbar(xbin_mid[msk], y50[msk], yerr=[y50[msk] - y16[msk], y84[msk] - y50[msk]], color='k', label='Bolshoi+SAM') #load Behroozi et al fit data BF = N.loadtxt(BFits[ii + 1]) #plot Behroozi data if ii == 6: ax.plot(BF[:, 0], BF[:, 1], color='r', ls='--', label='Behroozi et al.') else: ax.plot(BF[:, 0], BF[:, 1], color='r', ls='-', label='Behroozi et al.') #output some information logging.debug(BFits[ii + 1]) #mark the redshift if ii < 5: P.text(0.5, 0.93, r'$ z \sim %.1f $' % (rd), horizontalalignment='center', verticalalignment='center', transform=ax.transAxes, fontsize=12) elif ii == 5: P.text(0.5, 0.93, r'$z \sim %.1f (s)\ \& \ %.1f (d)$' % (rd, rd + 1), horizontalalignment='center', verticalalignment='center', transform=ax.transAxes, fontsize=12) #set axes scales and labels ax.set_xlim(xmin - 0.1, xmax) ax.set_ylim(ymin, ymax) #set small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5.) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5.) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) #set legend if ii == 4: ax.legend(shadow=True, fancybox=True, numpoints=1, loc='lower right') #set ylabel if ii == 0 or ii == 3: ax.set_ylabel(r'$\log_{10} \left (\frac{M_{\star}}{M_{\mathrm{dm}}} \right )$') #set xlabel if ii == 4: # or ii == 3 or ii == 5: ax.set_xlabel(r'$\log_{10} \left ( M_{\mathrm{dm}} \ [\mathrm{M}_{\odot}] \right )$') #remove some y ticks if ii == 0 or ii == 3: ax.set_yticks(ax.get_yticks()[:-1]) else: ax.set_yticklabels([]) #remove some x ticks if ii == 3 or ii == 4 or ii == 5: #ax.set_xticks(ax.get_xticks()[:-1]) continue elif ii == 6: continue else: ax.set_xticklabels([]) P.savefig(output_folder + outfile + 'Multi.pdf') P.close()
def stellarmassfunc_plot(path, database, redshifts, output_folder, outfile, mmax=12.5, mmin=8.0, nbins=30, nvolumes=15, lowlim=-4.9): ''' Plots stellar mass functions as a function of redshift. Compares to observations. ''' #get a colour scheme cols = pt.give_colours() #scale the SAM's output masses multiply = 1e9 #make the figure and axes instance fig = P.figure() ax = fig.add_subplot(111) #get obs constrains obs, ids = SMF.stellarMfs() o = [] o.append([ '$z \sim 1$: Perez-Gonzalez et al. 2007', (obs.id == 1) & (obs.z_low > 0.99) & (obs.z_up < 1.4) ]) #o.append(['$z \sim 1$: Drory et al. 2004', (obs.id == 5) & (obs.z_low > 1.) & (obs.z_up < 1.2)]) o.append([ '$z \sim 2$: Perez-Gonzalez et al. 2007', (obs.id == 1) & (obs.z_low > 1.99) & (obs.z_up < 2.6) ]) #o.append(['$z \sim 2$: Fontana et al. 2006', (obs.id == 6) & (obs.z_low > 1.99) & (obs.z_up < 3.01)]) #o.append(['$z \sim 2$: Marchesini et al. 2008', (obs.id == 7) & (obs.z_low > 1.99) & (obs.z_up < 3.01)]) o.append([ '$z \sim 3$: Perez-Gonzalez et al. 2007', (obs.id == 1) & (obs.z_low > 2.99) & (obs.z_up < 3.6) ]) o.append([ '$z \sim 4$: Perez-Gonzalez et al. 2007', (obs.id == 1) & (obs.z_low > 3.49) & (obs.z_up < 4.1) ]) highred = SMF.highRedshiftMFs() #make the observational plots for i, line in enumerate(o): label, mask = line[0], line[1] ms = obs.mstar[mask] mf = obs.mf[mask] errl = obs.err_low[mask] errh = obs.err_up[mask] msk = mf > -15.0 ax.errorbar(ms[msk], mf[msk], yerr=[errh[msk], errl[msk]], color=cols[i], ls=':', label=label) for i, key in enumerate(sorted(highred.iterkeys())): if key != 'stellar_mass': ax.plot(highred['stellar_mass'], highred[key], color=cols[i + 2], ls=':', marker='s', label='$%s:$ Gonzalez et al. 2011' % key.replace('=', '\sim')) #plot the different redshifts for ii, redshift in enumerate(redshifts): #get redshift, add 0.1 so that int/floor returns the closest int tmp = redshift.split() rd = int(float(tmp[2]) + 0.1) #generate the SQL query query = '''select mstar_disk, mbulge, gal_id from galpropz where ''' + redshift query += ' and (mstar_disk >= 0.0 or mbulge >= 0.0)' query += ' and mstar_disk + mbulge > 0.0' #get data from the SQLite3 db dat = db.sqlite.get_data_sqlite(path, database, query) #rename data for convenience disk = dat[:, 0] bulge = dat[:, 1] mstar = N.log10((disk * multiply) + (bulge * multiply)) #make a dictionary of data data = {} data['stellar_mass'] = mstar data['bulge_mass'] = bulge data['galaxy_id'] = dat[:, 2] #debug output ngal = len(mstar) logging.debug('%i galaxies found at z = %i' % (ngal, rd)) #calculate the stellar mass functions mfs = df.stellarMassFunction( data, mmin=mmin - 0.2, #mmax = mmax, nvols=nvolumes, nbins=nbins - 2 * rd, verbose=True) #plot the simulation data ax.plot(mfs['mass_bins'], mfs['mf_stellar_mass'], color=cols[ii], label='$z \sim %i$: Bolshoi + SAM' % rd) # ax.plot(mfs['mass_bins'], # mfs['mf_central_galaxies'], # color = cols[ii], # ls = '--', # label = '$z \sim %i$: Bolshoi + SAM (CG)' % rd) #set axes scales and labels ax.set_xlim(mmin, 12.0) ax.set_ylim(lowlim, -1.0) ax.set_xlabel( r'$\log_{10} \left ( M_{\star} \ [\mathrm{M}_{\odot}] \right )$') ax.set_ylabel( r'$\log_{10} \left ( \frac{\mathrm{d}N}{\mathrm{d}\log_{10} M_{\star}} \right ) \quad [\mathrm{Mpc}^{-3}\ \mathrm{dex}^{-1}] $' ) #set small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) P.legend(shadow=True, fancybox=True, numpoints=1) P.savefig(output_folder + outfile + '.pdf') P.close()
def stellarmassfunc_plot(path, database, redshifts, output_folder, outfile, mmax=12.5, mmin=8.0, nbins=30, nvolumes=15, lowlim=-4.9): ''' Plots stellar mass functions as a function of redshift. Compares to observations. ''' #get a colour scheme cols = pt.give_colours() #scale the SAM's output masses multiply = 1e9 #make the figure and axes instance fig = P.figure() ax = fig.add_subplot(111) #get obs constrains obs, ids = SMF.stellarMfs() o = [] o.append(['$z \sim 1$: Perez-Gonzalez et al. 2007', (obs.id == 1) & (obs.z_low > 0.99) & (obs.z_up < 1.4)]) #o.append(['$z \sim 1$: Drory et al. 2004', (obs.id == 5) & (obs.z_low > 1.) & (obs.z_up < 1.2)]) o.append(['$z \sim 2$: Perez-Gonzalez et al. 2007', (obs.id == 1) & (obs.z_low > 1.99) & (obs.z_up < 2.6)]) #o.append(['$z \sim 2$: Fontana et al. 2006', (obs.id == 6) & (obs.z_low > 1.99) & (obs.z_up < 3.01)]) #o.append(['$z \sim 2$: Marchesini et al. 2008', (obs.id == 7) & (obs.z_low > 1.99) & (obs.z_up < 3.01)]) o.append(['$z \sim 3$: Perez-Gonzalez et al. 2007', (obs.id == 1) & (obs.z_low > 2.99) & (obs.z_up < 3.6)]) o.append(['$z \sim 4$: Perez-Gonzalez et al. 2007', (obs.id == 1) & (obs.z_low > 3.49) & (obs.z_up < 4.1)]) highred = SMF.highRedshiftMFs() #make the observational plots for i, line in enumerate(o): label, mask = line[0], line[1] ms = obs.mstar[mask] mf = obs.mf[mask] errl = obs.err_low[mask] errh = obs.err_up[mask] msk = mf > - 15.0 ax.errorbar(ms[msk], mf[msk], yerr=[errh[msk], errl[msk]], color=cols[i], ls=':', label=label) for i, key in enumerate(sorted(highred.iterkeys())): if key != 'stellar_mass': ax.plot(highred['stellar_mass'], highred[key], color=cols[i + 2], ls=':', marker='s', label='$%s:$ Gonzalez et al. 2011' % key.replace('=', '\sim')) #plot the different redshifts for ii, redshift in enumerate(redshifts): #get redshift, add 0.1 so that int/floor returns the closest int tmp = redshift.split() rd = int(float(tmp[2]) + 0.1) #generate the SQL query query = '''select mstar_disk, mbulge, gal_id from galpropz where ''' + redshift query += ' and (mstar_disk >= 0.0 or mbulge >= 0.0)' query += ' and mstar_disk + mbulge > 0.0' #get data from the SQLite3 db dat = db.sqlite.get_data_sqlite(path, database, query) #rename data for convenience disk = dat[:, 0] bulge = dat[:, 1] mstar = N.log10((disk * multiply) + (bulge * multiply)) #make a dictionary of data data = {} data['stellar_mass'] = mstar data['bulge_mass'] = bulge data['galaxy_id'] = dat[:, 2] #debug output ngal = len(mstar) logging.debug('%i galaxies found at z = %i' % (ngal, rd)) #calculate the stellar mass functions mfs = df.stellarMassFunction(data, mmin=mmin - 0.2, #mmax = mmax, nvols=nvolumes, nbins=nbins - 2 * rd, verbose=True) #plot the simulation data ax.plot(mfs['mass_bins'], mfs['mf_stellar_mass'], color=cols[ii], label='$z \sim %i$: Bolshoi + SAM' % rd) # ax.plot(mfs['mass_bins'], # mfs['mf_central_galaxies'], # color = cols[ii], # ls = '--', # label = '$z \sim %i$: Bolshoi + SAM (CG)' % rd) #set axes scales and labels ax.set_xlim(mmin, 12.0) ax.set_ylim(lowlim, -1.0) ax.set_xlabel(r'$\log_{10} \left ( M_{\star} \ [\mathrm{M}_{\odot}] \right )$') ax.set_ylabel( r'$\log_{10} \left ( \frac{\mathrm{d}N}{\mathrm{d}\log_{10} M_{\star}} \right ) \quad [\mathrm{Mpc}^{-3}\ \mathrm{dex}^{-1}] $') #set small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) P.legend(shadow=True, fancybox=True, numpoints=1) P.savefig(output_folder + outfile + '.pdf') P.close()