コード例 #1
0
def plot_uvj_vs_icd():
    galaxies = pickle.load(open('galaxies.pickle', 'rb'))
    galaxies = filter(lambda galaxy: galaxy.ICD_IH != None, galaxies)
    galaxies = filter(lambda galaxy: galaxy.sersic != None and \
            galaxy.ston_I > 10, galaxies)

    #Upper and Lower limit arrow verts
    arrowup_verts = [[0., 0.], [-1., -1], [0., 0.], [0., -2.], [0., 0.],
                     [1, -1]]
    #arrowdown_verts = [[0.,0.], [-1., 1], [0.,0.],
    #    [0.,2.], [0.,0.], [1, 1]]

    F = pyl.figure(1, figsize=(8, 3))
    grid = AxesGrid(F,
                    111,
                    nrows_ncols=(1, 4),
                    axes_pad=0.1,
                    add_all=True,
                    aspect=False,
                    share_all=False)

    ax1 = grid[0]
    ax2 = grid[1]
    ax3 = grid[2]
    ax4 = grid[3]

    for galaxy in galaxies:
        if galaxy.sersic < 1.:
            if galaxy.ICD_IH * 100 < 50:
                col1 = ax1.scatter(galaxy.Mass,
                                   galaxy.ICD_IH * 100.,
                                   s=25,
                                   c='0.8',
                                   edgecolor='0.8')
            else:
                col1 = ax1.scatter(galaxy.Mass,
                                   50,
                                   marker=None,
                                   s=100,
                                   verts=arrowup_verts)
        if 1. < galaxy.sersic < 2.:
            if galaxy.ICD_IH * 100 < 50:
                col2 = ax2.scatter(galaxy.Mass,
                                   galaxy.ICD_IH * 100.,
                                   s=25,
                                   c='0.8',
                                   edgecolor='0.8')
            else:
                col2 = ax2.scatter(galaxy.Mass,
                                   50,
                                   marker=None,
                                   s=100,
                                   verts=arrowup_verts)
        if 2. < galaxy.sersic < 3.:
            if galaxy.ICD_IH * 100 < 50:
                col3 = ax3.scatter(galaxy.Mass,
                                   galaxy.ICD_IH * 100.,
                                   s=25,
                                   c='0.8',
                                   edgecolor='0.8')
            else:
                col3 = ax3.scatter(galaxy.Mass,
                                   50,
                                   marker=None,
                                   s=100,
                                   verts=arrowup_verts)
        if 3. < galaxy.sersic:
            if galaxy.ICD_IH * 100 < 50:
                col4 = ax4.scatter(galaxy.Mass,
                                   galaxy.ICD_IH * 100.,
                                   s=25,
                                   c='0.8',
                                   edgecolor='0.8')
            else:
                col4 = ax4.scatter(galaxy.Mass,
                                   50,
                                   marker=None,
                                   s=100,
                                   verts=arrowup_verts)

    # Add the box and whiskers
    galaxies1 = filter(lambda galaxy: galaxy.ston_I > 10. and \
        galaxy.sersic < 1, galaxies)
    galaxies1 = pyl.asarray(galaxies1)
    galaxies2 = filter(lambda galaxy: galaxy.ston_I > 10. and \
        1 < galaxy.sersic < 2, galaxies)
    galaxies2 = pyl.asarray(galaxies2)
    galaxies3 = filter(lambda galaxy: galaxy.ston_I > 10. and \
        2 < galaxy.sersic < 3, galaxies)
    galaxies3 = pyl.asarray(galaxies3)
    galaxies4 = filter(lambda galaxy: galaxy.ston_I > 10. and \
        3 < galaxy.sersic, galaxies)
    galaxies4 = pyl.asarray(galaxies4)

    x1 = [galaxy.Mass for galaxy in galaxies1]
    x2 = [galaxy.Mass for galaxy in galaxies2]
    x3 = [galaxy.Mass for galaxy in galaxies3]
    x4 = [galaxy.Mass for galaxy in galaxies4]

    grid1 = []
    grid2 = []
    grid3 = []
    grid4 = []

    from boxplot_percentile_width import percentile_box_plot as pbp

    bins_x = pyl.array([8.5, 9., 9.5, 10., 11])
    for i in range(bins_x.size - 1):
        xmin = bins_x[i]
        xmax = bins_x[i + 1]
        cond = [cond1 and cond2 for cond1, cond2 in zip(x1 >= xmin, x1 < xmax)]
        grid1.append(galaxies1.compress(cond))

    icd1 = []
    for i in range(len(grid1)):
        icd1.append([galaxy.ICD_IH * 100 for galaxy in grid1[i]])
    width = pyl.diff(bins_x)
    index = pyl.delete(bins_x, -1) + 0.25
    index[-1] = index[-1] + 0.25
    bp1 = pbp(ax1, icd1, indexer=list(index), width=width)

    bins_x = pyl.array([8.5, 9., 9.5, 10., 10.5, 11.5])
    for i in range(bins_x.size - 1):
        xmin = bins_x[i]
        xmax = bins_x[i + 1]
        cond = [cond1 and cond2 for cond1, cond2 in zip(x2 >= xmin, x2 < xmax)]
        grid2.append(galaxies2.compress(cond))
    icd2 = []
    for i in range(len(grid2)):
        icd2.append([galaxy.ICD_IH * 100 for galaxy in grid2[i]])
    width = pyl.diff(bins_x)
    index = pyl.delete(bins_x, -1) + 0.25
    index[-1] = index[-1] + 0.25
    bp2 = pbp(ax2, icd2, indexer=list(index), width=width)

    bins_x = pyl.array([8.5, 9.5, 10., 11.])
    for i in range(bins_x.size - 1):
        xmin = bins_x[i]
        xmax = bins_x[i + 1]
        cond = [cond1 and cond2 for cond1, cond2 in zip(x3 >= xmin, x3 < xmax)]
        grid3.append(galaxies3.compress(cond))
    icd3 = []
    for i in range(len(grid3)):
        icd3.append([galaxy.ICD_IH * 100 for galaxy in grid3[i]])
    width = pyl.diff(bins_x)
    index = pyl.delete(bins_x, -1) + 0.25
    index[-1] = index[-1] + 0.25
    index[0] = index[0] + 0.25
    bp3 = pbp(ax3, icd3, indexer=list(index), width=width)

    bins_x = pyl.array([8.5, 9., 9.5, 10., 10.5, 11., 12.])
    for i in range(bins_x.size - 1):
        xmin = bins_x[i]
        xmax = bins_x[i + 1]
        cond = [cond1 and cond2 for cond1, cond2 in zip(x4 >= xmin, x4 < xmax)]
        grid4.append(galaxies4.compress(cond))
    icd4 = []
    for i in range(len(grid4)):
        icd4.append([galaxy.ICD_IH * 100 for galaxy in grid4[i]])
    width = pyl.diff(bins_x)
    index = pyl.delete(bins_x, -1) + 0.25
    index[-1] = index[-1] + 0.25
    print 'ajsdf'
    bp4 = pbp(ax4, icd4, indexer=list(index), width=width)

    ax1.set_xticks([8, 9, 10, 11])
    ax2.set_xticks([8, 9, 10, 11, 12])
    ax3.set_xticks([8, 9, 10, 11])
    ax4.set_xticks([8, 9, 10, 11, 12])

    ax1.set_ylim(0, 50)
    ax2.set_ylim(0, 50)
    ax3.set_ylim(0, 50)
    ax4.set_ylim(0, 50)

    ax1.set_xlim(8, 12.5)
    ax2.set_xlim(8, 12.5)
    ax3.set_xlim(8, 12.5)
    ax4.set_xlim(8, 12.5)

    ax1.set_ylabel(r'$\xi[i_{775},H_{160}]$ (%)')
    ax1.set_title('n < 1')
    ax2.set_title('1 < n < 2')
    ax3.set_title('2 < n < 3')
    ax4.set_title('3 < n')

    pyl.figtext(.5,
                .05,
                r'Log Mass $(M_{\odot})$',
                fontsize=18,
                horizontalalignment='center')
    ax1.axhline(0, lw=2, zorder=0)
    ax2.axhline(0, lw=2, zorder=0)
    ax3.axhline(0, lw=2, zorder=0)
    ax4.axhline(0, lw=2, zorder=0)

    import matplotlib.font_manager
    line1 = pyl.Line2D([], [],
                       marker='o',
                       mfc='0.8',
                       mec='0.8',
                       markersize=8,
                       linewidth=0)
    line2 = pyl.Line2D([], [],
                       marker='s',
                       mec='#348ABD',
                       mfc='None',
                       markersize=10,
                       linewidth=0,
                       markeredgewidth=2)
    line3 = pyl.Line2D([], [], color='#A60628', linewidth=2)
    prop = matplotlib.font_manager.FontProperties(size='small')
    ax3.legend((line1, line2, line3), ('Data', 'Quartiles', 'Medians'),
               loc='upper center',
               prop=prop,
               ncol=1)

    pyl.tight_layout()
    pyl.subplots_adjust(bottom=0.21, left=0.11)
    pyl.show()
コード例 #2
0
def plot_icd_vs_mass():
    galaxies = pickle.load(open('galaxies.pickle', 'rb'))
    galaxies = filter(lambda galaxy: 0.06 * galaxy.halflight *\
            astCalc.da(galaxy.z)*1000/206265. > 2, galaxies)

    # Make figure
    f1 = pyl.figure(1, figsize=(6, 4))
    f1s1 = f1.add_subplot(121)
    f1s2 = f1.add_subplot(122)
    #    f1s3 = f1.add_subplot(223)
    #    f1s4 = f1.add_subplot(224)

    #Upper and Lower limit arrow verts
    arrowup_verts = [[0., 0.], [-1., -1], [0., 0.], [0., -2.], [0., 0.],
                     [1, -1], [0, 0]]
    #arrowdown_verts = [[0.,0.], [-1., 1], [0.,0.],
    #    [0.,2.], [0.,0.], [1, 1]]

    for galaxy in galaxies:
        if galaxy.ston_I > 30. and galaxy.ICD_IH != None:
            # Add arrows first
            if galaxy.ICD_IH > 0.5:
                f1s1.scatter(galaxy.Mass,
                             0.5 * 100,
                             s=100,
                             marker=None,
                             verts=arrowup_verts)
            else:
                f1s1.scatter(galaxy.Mass,
                             galaxy.ICD_IH * 100,
                             c='0.8',
                             marker='o',
                             s=25,
                             edgecolor='0.8')
                f1s2.scatter(galaxy.Mass,
                             galaxy.ICD_IH * 100,
                             c='0.8',
                             marker='o',
                             s=25,
                             edgecolor='0.8')
    '''
        if galaxy.ston_J > 30. and galaxy.ICD_JH != None:
            # Add arrows first
            if galaxy.ICD_JH > 0.12:
                f1s3.scatter(galaxy.Mass, 12, s=100, marker=None,
                    verts=arrowup_verts)
            else:
                f1s3.scatter(galaxy.Mass, galaxy.ICD_JH * 100, c='0.8',
                    marker='o', s=25, edgecolor='0.8')
                f1s4.scatter(galaxy.Mass, galaxy.ICD_JH * 100, c='0.8',
                    marker='o', s=25, edgecolor='0.8')
    '''
    # Add the box and whiskers
    galaxies2 = filter(lambda galaxy: galaxy.ston_I > 30., galaxies)
    galaxies2 = pyl.asarray(galaxies2)
    x = [galaxy.Mass for galaxy in galaxies2]
    ll = 8.5
    ul = 12
    #bins_x =pyl.arange(8.5, 12.5, 0.5)
    bins_x = pyl.array([8.5, 9., 9.5, 10., 10.5, 11., 12.])
    grid = []

    for i in range(bins_x.size - 1):
        xmin = bins_x[i]
        xmax = bins_x[i + 1]
        cond = [cond1 and cond2 for cond1, cond2 in zip(x >= xmin, x < xmax)]

        grid.append(galaxies2.compress(cond))
    icd = []
    for i in range(len(grid)):
        icd.append([galaxy.ICD_IH * 100 for galaxy in grid[i]])

    from boxplot_percentile_width import percentile_box_plot as pbp
    #bp1 = f1s1.boxplot(icd, positions=pyl.delete(bins_x,-1)+0.25, sym='')
    width = pyl.diff(bins_x)
    index = pyl.delete(bins_x, -1) + 0.25
    index[-1] = index[-1] + 0.25
    pbp(f1s1, icd, indexer=list(index), width=width)
    pbp(f1s2, icd, indexer=list(index), width=width)
    '''
    # Add the box and whiskers
    galaxies2 = filter(lambda galaxy: galaxy.ston_J > 30., galaxies)
    galaxies2 = pyl.asarray(galaxies2)
    x = [galaxy.Mass for galaxy in galaxies2]
    ll = 8.5
    ul= 12
    #bins_x =pyl.linspace(ll, ul, 7)
    #bins_x =pyl.arange(8.5, 12.5, 0.5)
    bins_x =pyl.array([8.5, 9., 9.5, 10., 10.5, 11., 12.])
    grid = []

    for i in range(bins_x.size-1):
        xmin = bins_x[i]
        xmax = bins_x[i+1]
        cond=[cond1 and cond2 for cond1, cond2 in zip(x>=xmin, x<xmax)]

        grid.append(galaxies2.compress(cond))
    icd = []
    for i in range(len(grid)):
        icd.append([galaxy.ICD_JH*100 for galaxy in grid[i]])
    #bp2 = f1s2.boxplot(icd, positions=pyl.delete(bins_x,-1)+0.25, sym='')
    width = pyl.diff(bins_x)
    index = pyl.delete(bins_x,-1) + 0.25
    index[-1] = index[-1] + 0.25
    pbp(f1s3, icd, indexer=list(index), width=width)
    pbp(f1s4, icd, indexer=list(index), width=width)

    '''
    # Finish Plot
    # Tweak colors on the boxplot
    #pyl.setp(bp1['boxes'], lw=2)
    #pyl.setp(bp1['whiskers'], lw=2)
    #pyl.setp(bp1['medians'], lw=2)
    #pyl.setp(bp2['boxes'], lw=2)
    #pyl.setp(bp2['whiskers'], lw=2)
    #pyl.setp(bp2['medians'], lw=2)
    #pyl.setp(bp['fliers'], color='#8CFF6F', marker='+')

    #f1s1.axvspan(7.477, 9, facecolor='#FFFDD0', ec='None', zorder=0)
    #f1s1.axvspan(11, 12, facecolor='#FFFDD0', ec='None', zorder=0)
    #f1s2.axvspan(7.477, 9, facecolor='#FFFDD0', ec='None', zorder=0)
    #f1s2.axvspan(11, 12, facecolor='#FFFDD0', ec='None', zorder=0)

    f1s1.set_xlim(8, 12)
    f1s2.set_xlim(8, 12)
    #    f1s3.set_xlim(8,12)
    #    f1s4.set_xlim(8,12)

    f1s1.set_ylim(-10, 50)
    f1s2.set_ylim(0, 15)
    #    f1s3.set_ylim(-5,12)
    #    f1s4.set_ylim(-1,3)

    f1s1.set_xticks([8, 9, 10, 11, 12])
    #    f1s1.set_xticklabels([])
    f1s2.set_xticks([8, 9, 10, 11, 12])
    #    f1s2.set_xticklabels([])
    #    f1s3.set_xticks([8,9,10,11,12])
    #    f1s4.set_xticks([8,9,10,11,12])

    #    f1s4.set_yticks([-1, 0, 1, 2, 3])

    f1s1.set_ylabel(r"$\xi[i_{775},H_{160}]$ (%)")
    f1s1.set_xlabel(r"Log Mass ($M_{\odot})$")
    f1s2.set_xlabel(r"Log Mass ($M_{\odot})$")
    #    f1s3.set_ylabel(r"$\xi[J_{125},H_{160}]$ (%)")

    import matplotlib.font_manager
    line1 = pyl.Line2D([], [],
                       marker='o',
                       mfc='0.8',
                       mec='0.8',
                       markersize=8,
                       linewidth=0)
    line2 = pyl.Line2D([], [],
                       marker='s',
                       mec='#348ABD',
                       mfc='None',
                       markersize=10,
                       linewidth=0,
                       markeredgewidth=2)
    line3 = pyl.Line2D([], [], color='#A60628', linewidth=2)
    prop = matplotlib.font_manager.FontProperties(size='small')
    pyl.figlegend((line1, line2, line3), ('Data', 'Quartiles', 'Medians'),
                  'lower center',
                  prop=prop,
                  ncol=3)

    from matplotlib.patches import ConnectionPatch
    xy = (12, 15)
    xy2 = (8, 15)
    con = ConnectionPatch(xyA=xy,
                          xyB=xy2,
                          coordsA='data',
                          coordsB='data',
                          axesA=f1s1,
                          axesB=f1s2)
    xy = (12, 0)
    xy2 = (8, 0)
    con2 = ConnectionPatch(xyA=xy,
                           xyB=xy2,
                           coordsA='data',
                           coordsB='data',
                           axesA=f1s1,
                           axesB=f1s2)
    f1s1.add_artist(con)
    f1s1.add_artist(con2)

    xy = (12, 3)
    xy2 = (8, 3)
    #   con = ConnectionPatch(xyA=xy, xyB=xy2, coordsA='data', coordsB='data',
    #       axesA=f1s3, axesB=f1s4)
    xy = (12, -1)
    xy2 = (8, -1)
    #    con2 = ConnectionPatch(xyA=xy, xyB=xy2, coordsA='data', coordsB='data',
    #        axesA=f1s3, axesB=f1s4)
    #   f1s3.add_artist(con)
    #   f1s3.add_artist(con2)

    pyl.draw()
    pyl.show()
コード例 #3
0
ファイル: plot_icd_mass_box_width.py プロジェクト: boada/ICD
def plot_icd_vs_mass():
    galaxies = pickle.load(open('galaxies.pickle','rb'))
#    galaxies = filter(lambda galaxy: 0.06 * galaxy.halflight *\
#           astCalc.da(galaxy.z)*1000/206265. > 2, galaxies)

    # Make figure
    f1 = pyl.figure(1, figsize=(6,4))
    f1s1 = f1.add_subplot(121)
    f1s2 = f1.add_subplot(122)
#    f1s3 = f1.add_subplot(223)
#    f1s4 = f1.add_subplot(224)

    #Upper and Lower limit arrow verts
    arrowup_verts = [[0.,0.], [-1., -1], [0.,0.],
        [0.,-2.], [0.,0.], [1,-1], [0,0]]
    #arrowdown_verts = [[0.,0.], [-1., 1], [0.,0.],
    #    [0.,2.], [0.,0.], [1, 1]]

    for galaxy in galaxies:
        if galaxy.ston_I > 10. and galaxy.ICD_IH != None:
            # Add arrows first
            if galaxy.ICD_IH > 0.5:
                f1s1.scatter(galaxy.Mass, 0.5*100, s=100, marker=None,
                    verts=arrowup_verts)
            else:
                f1s1.scatter(galaxy.Mass, galaxy.ICD_IH * 100, c='0.8',
                    marker='o', s=25, edgecolor='0.8')
                f1s2.scatter(galaxy.Mass, galaxy.ICD_IH * 100, c='0.8',
                    marker='o', s=25, edgecolor='0.8')

    # Add the box and whiskers
    galaxies2 = filter(lambda galaxy: galaxy.ston_I > 10., galaxies)
    galaxies2 = pyl.asarray(galaxies2)
    x = [galaxy.Mass for galaxy in galaxies2]
    ll = 8.5
    ul= 12
    bins_x =pyl.array([8.5, 9., 9.5, 10., 10.5, 11., 12.])
    grid = []

    for i in range(bins_x.size-1):
        xmin = bins_x[i]
        xmax = bins_x[i+1]
        cond=[cond1 and cond2 for cond1, cond2 in zip(x>=xmin, x<xmax)]

        grid.append(galaxies2.compress(cond))
    icd = []
    for i in range(len(grid)):
        icd.append([galaxy.ICD_IH*100 for galaxy in grid[i]])

    from boxplot_percentile_width import percentile_box_plot as pbp
    #bp1 = f1s1.boxplot(icd, positions=pyl.delete(bins_x,-1)+0.25, sym='')
    width = pyl.diff(bins_x)
    index = pyl.delete(bins_x,-1) + 0.25
    index[-1] = index[-1] + 0.25
    pbp(f1s1, icd, indexer=list(index), width=width)
    pbp(f1s2, icd, indexer=list(index), width=width)

    f1s1.set_xlim(8,12)
    f1s2.set_xlim(8,12)

    f1s1.set_ylim(-10,50)
    f1s2.set_ylim(0,15)

    f1s1.set_xticks([8,9,10,11,12])
    f1s2.set_xticks([8,9,10,11,12])


    f1s1.set_ylabel(r"$\xi[i_{775},H_{160}]$ (%)")
    f1s1.set_xlabel(r"Log Mass ($M_{\odot})$")
    f1s2.set_xlabel(r"Log Mass ($M_{\odot})$")

    import matplotlib.font_manager
    line1 = pyl.Line2D([], [], marker='o', mfc='0.8', mec='0.8', markersize=8,
        linewidth=0)
    line2 = pyl.Line2D([], [], marker='s', mec='#348ABD', mfc='None',
        markersize=10, linewidth=0, markeredgewidth=2)
    line3 = pyl.Line2D([], [], color='#A60628', linewidth=2)
    prop = matplotlib.font_manager.FontProperties(size='small')
    pyl.figlegend((line1, line2, line3), ('Data', 'Quartiles',
        'Medians'), 'lower center', prop=prop, ncol=3)

    from matplotlib.patches import ConnectionPatch
    xy = (12, 15)
    xy2 = (8, 15)
    con = ConnectionPatch(xyA=xy, xyB=xy2, coordsA='data', coordsB='data',
        axesA=f1s1, axesB=f1s2)
    xy = (12, 0)
    xy2 = (8, 0)
    con2 = ConnectionPatch(xyA=xy, xyB=xy2, coordsA='data', coordsB='data',
        axesA=f1s1, axesB=f1s2)
    f1s1.add_artist(con)
    f1s1.add_artist(con2)

    xy = (12, 3)
    xy2 = (8, 3)
    xy = (12, -1)
    xy2 = (8, -1)

    pyl.draw()
    pyl.show()
コード例 #4
0
def plot_uvj_vs_icd():
    galaxies = pickle.load(open('galaxies.pickle','rb'))
    galaxies = filter(lambda galaxy: galaxy.ICD_IH != None, galaxies)
    galaxies = filter(lambda galaxy: galaxy.sersic != None and \
            galaxy.ston_I > 30, galaxies)

    #Upper and Lower limit arrow verts
    arrowup_verts = [[0.,0.], [-1., -1], [0.,0.],
        [0.,-2.], [0.,0.], [1,-1]]
    #arrowdown_verts = [[0.,0.], [-1., 1], [0.,0.],
    #    [0.,2.], [0.,0.], [1, 1]]

    F = pyl.figure(1,figsize=(8,3))
    grid = AxesGrid(F, 111,
            nrows_ncols=(1,4),
            axes_pad = 0.1,
            add_all=True,
            aspect=False,
            share_all = True)

    ax1 = grid[0]
    ax2 = grid[1]
    ax3 = grid[2]
    ax4 = grid[3]

    for galaxy in galaxies:
        if galaxy.sersic < 1.:
            col1 =ax1.scatter(galaxy.Mass, galaxy.ICD_IH * 100.,
                s=25, c='0.8', edgecolor='0.8')
        if 1. < galaxy.sersic < 2.:
                col2 =ax2.scatter(galaxy.Mass, galaxy.ICD_IH * 100.,
                    s=25, c='0.8', edgecolor='0.8')
        if 2. < galaxy.sersic < 3.:
                col3 =ax3.scatter(galaxy.Mass, galaxy.ICD_IH * 100.,
                    s=25, c='0.8', edgecolor='0.8')
        if 3. <  galaxy.sersic:
            if galaxy.ICD_IH*100 < 50:
                col4 =ax4.scatter(galaxy.Mass, galaxy.ICD_IH * 100.,
                    s=25, c='0.8', edgecolor='0.8')
            else:
                col4 = ax4.scatter(galaxy.Mass, 50, marker=None, s=100,
                        verts=arrowup_verts)

    # Add the box and whiskers
    galaxies1 = filter(lambda galaxy: galaxy.ston_I > 30. and \
        galaxy.sersic < 1, galaxies)
    galaxies1 = pyl.asarray(galaxies1)
    galaxies2 = filter(lambda galaxy: galaxy.ston_I > 30. and \
        1 < galaxy.sersic < 2, galaxies)
    galaxies2 = pyl.asarray(galaxies2)
    galaxies3 = filter(lambda galaxy: galaxy.ston_I > 30. and \
        2 < galaxy.sersic < 3, galaxies)
    galaxies3 = pyl.asarray(galaxies3)
    galaxies4 = filter(lambda galaxy: galaxy.ston_I > 30. and \
        3 < galaxy.sersic, galaxies)
    galaxies4 = pyl.asarray(galaxies4)

    x1 = [galaxy.Mass for galaxy in galaxies1]
    x2 = [galaxy.Mass for galaxy in galaxies2]
    x3 = [galaxy.Mass for galaxy in galaxies3]
    x4 = [galaxy.Mass for galaxy in galaxies4]

    grid1 = []
    grid2 = []
    grid3 = []
    grid4 = []

    from boxplot_percentile_width import percentile_box_plot as pbp

    bins_x =pyl.array([8.5, 9., 9.5, 10., 11])
    for i in range(bins_x.size-1):
        xmin = bins_x[i]
        xmax = bins_x[i+1]
        cond=[cond1 and cond2 for cond1, cond2 in zip(x1>=xmin, x1<xmax)]
        grid1.append(galaxies1.compress(cond))

    icd1 = []
    for i in range(len(grid1)):
        icd1.append([galaxy.ICD_IH*100 for galaxy in grid1[i]])
    width = pyl.diff(bins_x)
    index = pyl.delete(bins_x,-1) + 0.25
    index[-1] = index[-1] + 0.25
    bp1 = pbp(ax1, icd1, indexer=list(index), width=width)

    bins_x =pyl.array([8.5, 9., 9.5, 10., 10.5 ,11.5])
    for i in range(bins_x.size-1):
        xmin = bins_x[i]
        xmax = bins_x[i+1]
        cond=[cond1 and cond2 for cond1, cond2 in zip(x2>=xmin, x2<xmax)]
        grid2.append(galaxies2.compress(cond))
    icd2 = []
    for i in range(len(grid2)):
        icd2.append([galaxy.ICD_IH*100 for galaxy in grid2[i]])
    width = pyl.diff(bins_x)
    index = pyl.delete(bins_x,-1) + 0.25
    index[-1] = index[-1] + 0.25
    bp2 = pbp(ax2, icd2, indexer=list(index), width=width)

    bins_x =pyl.array([8.5, 9.5, 10., 11.])
    for i in range(bins_x.size-1):
        xmin = bins_x[i]
        xmax = bins_x[i+1]
        cond=[cond1 and cond2 for cond1, cond2 in zip(x3>=xmin, x3<xmax)]
        grid3.append(galaxies3.compress(cond))
    icd3 = []
    for i in range(len(grid3)):
        icd3.append([galaxy.ICD_IH*100 for galaxy in grid3[i]])
    width = pyl.diff(bins_x)
    index = pyl.delete(bins_x,-1) + 0.25
    index[-1] = index[-1] + 0.25
    index[0] = index[0] + 0.25
    bp3 = pbp(ax3, icd3, indexer=list(index), width=width)

    bins_x =pyl.array([8.5, 9., 9.5, 10., 10.5, 11., 12.])
    for i in range(bins_x.size-1):
        xmin = bins_x[i]
        xmax = bins_x[i+1]
        cond=[cond1 and cond2 for cond1, cond2 in zip(x4>=xmin, x4<xmax)]
        grid4.append(galaxies4.compress(cond))
    icd4 = []
    for i in range(len(grid4)):
        icd4.append([galaxy.ICD_IH*100 for galaxy in grid4[i]])
    width = pyl.diff(bins_x)
    index = pyl.delete(bins_x,-1) + 0.25
    index[-1] = index[-1] + 0.25
    print 'ajsdf'
    bp4 = pbp(ax4, icd4, indexer=list(index), width=width)

    ax1.set_xticks([8, 9, 10, 11])
    ax2.set_xticks([8, 9, 10, 11])
    ax3.set_xticks([8, 9, 10, 11])
    ax4.set_xticks([8, 9, 10, 11])

    ax1.set_ylim(0, 50)
    ax2.set_ylim(0, 50)
    ax3.set_ylim(0, 50)
    ax4.set_ylim(0, 50)

    ax1.set_ylabel(r'$\xi[i_{775},H_{160}]$ (%)')
    ax1.set_title('n < 1')
    ax2.set_title('1 < n < 2')
    ax3.set_title('2 < n < 3')
    ax4.set_title('3 < n')

    pyl.figtext(.5, .05, r'Log Mass $(M_{\odot})$',fontsize=18,
        horizontalalignment='center')
    ax1.axhline(0, lw=2, zorder=0)
    ax2.axhline(0, lw=2, zorder=0)
    ax3.axhline(0, lw=2, zorder=0)
    ax4.axhline(0, lw=2, zorder=0)

    import matplotlib.font_manager
    line1 = pyl.Line2D([], [], marker='o', mfc='0.8', mec='0.8', markersize=8,
            linewidth=0)
    line2 = pyl.Line2D([], [], marker='s', mec='#348ABD', mfc='None',
            markersize=10, linewidth=0, markeredgewidth=2)
    line3 = pyl.Line2D([], [], color='#A60628', linewidth=2)
    prop = matplotlib.font_manager.FontProperties(size='small')
    ax3.legend((line1, line2, line3), ('Data', 'Quartiles',
        'Medians'), loc='upper center', prop=prop, ncol=1)

    pyl.tight_layout()
    pyl.subplots_adjust(bottom=0.21, left=0.11)
    pyl.show()