Python pylab 模块,axhline() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用pylab.axhline()

项目:astromalign    作者:dstndstn    | 项目源码 | 文件源码
def edgescatter(self, ps):
        for ei,X in enumerate(self.edges):
            i,j = X[:2]
            matchdRA, matchdDec = X[10:12]
            mu = X[9]
            A = self.alignments[ei]

            plt.clf()
            if len(matchdRA) > 1000:
                plothist(matchdRA, matchdDec, 101)
            else:
                plt.plot(matchdRA, matchdDec, 'k.', alpha=0.5)
            plt.axvline(0, color='0.5')
            plt.axhline(0, color='0.5')
            plt.axvline(mu[0], color='b')
            plt.axhline(mu[1], color='b')
            for nsig in [1,2]:
                X,Y = A.getContours(nsigma=nsig)
                plt.plot(X, Y, 'b-')
            plt.xlabel('delta-RA (arcsec)')
            plt.ylabel('delta-Dec (arcsec)')
            plt.axis('scaled')
            ps.savefig()
项目:PyME    作者:vikramsunkara    | 项目源码 | 文件源码
def plot_2D_contour(states,p,labels,inter=False):
    import pylab as pl

    from pyme.statistics import expectation as EXP
    exp = EXP((states,p)) 
    X = np.unique(states[0,:])
    Y = np.unique(states[1,:])
    X_len = len(X)
    Y_len = len(Y)
    Z = np.zeros((X.max()+1,Y.max()+1))
    for i in range(len(p)):
        Z[states[0,i],states[1,i]] = p[i]

    Z = np.where(Z < 1e-8,0.0,Z)
    pl.clf()
    XX, YY = np.meshgrid(X,Y)   
    pl.contour(range(X.max()+1),range(Y.max()+1),Z.T)
    pl.axhline(y=exp[1])
    pl.axvline(x=exp[0])
    pl.xlabel(labels[0])
    pl.ylabel(labels[1])
    if inter == True:
        pl.draw()
    else:
        pl.show()
项目:astromalign    作者:dstndstn    | 项目源码 | 文件源码
def plotalignment(A, nbins=200, M=None, rng=None, doclf=True, docolorbar=True,
                  docutcircle=True, docontours=True, dologhist=False,
                  doaxlines=False, imshowargs={}):
    import pylab as plt
    from astrometry.util.plotutils import plothist, loghist
    if doclf:
        plt.clf()
    if M is None:
        M = A.match
    if dologhist:
        f = loghist
    else:
        f = plothist
    H,xe,ye = f(M.dra_arcsec*1000., M.ddec_arcsec*1000., nbins,
                range=rng, doclf=doclf, docolorbar=docolorbar,
                imshowargs=imshowargs)
    ax = plt.axis()
    if A is not None:
        # The EM fit is based on a subset of the matches;
        # draw the subset cut circle.
        if docutcircle:
            angle = np.linspace(0, 2.*pi, 360)
            plt.plot((A.cutcenter[0] + A.cutrange * np.cos(angle))*1000.,
                     (A.cutcenter[1] + A.cutrange * np.sin(angle))*1000., 'r-')
        if docontours:
            for i,c in enumerate(['b','c','g']*2):
                if i == A.ngauss:
                    break
                for nsig in [1,2]:
                    XY = A.getContours(nsig, c=i)
                    if XY is None:
                        break
                    X,Y = XY
                    plt.plot(X*1000., Y*1000., '-', color=c)#, alpha=0.5)
    if doaxlines:
        plt.axhline(0., color='b', alpha=0.5)
        plt.axvline(0., color='b', alpha=0.5)
    plt.axis(ax)
    plt.xlabel('dRA (mas)')
    plt.ylabel('dDec (mas)')
    return H,xe,ye
项目:livespin    作者:biocompibens    | 项目源码 | 文件源码
def getRotation(self, plot = True):
        if self.nComponents != 3:
            raise Exception("ERROR : not 3 centers")
        ## choice only surface based criteria
        areas = np.zeros(self.nComponents)
        for i in xrange(self.nComponents):
            areas[i] = self.params[6*i+3]*self.params[6*i+4]*np.pi
        goodcenters = range(self.nComponents)
        other = np.argmax(areas)
        goodcenters.pop(other)
        x3 = self.params[6*other+1]
        y3 = self.params[6*other+2]
        x1 = self.params[6*goodcenters[0]+1]
        y1 = self.params[6*goodcenters[0]+2]
        x2 = self.params[6*goodcenters[1]+1]
        y2 = self.params[6*goodcenters[1]+2]
        cx = (x1 + x2)/2.
        cy = (y1 + y2)/2.
        rot = acos((cy-y3) /1./ self.euclidian_dist(x3, y3, cx, cy))
        if x3-cx < 0:
            rot = -1.*rot
        if plot:
            pylab.subplot(2,2,1)
            pylab.plot([y3, cy], [x3, cx], 'm-', label = (x3-cx)>0)
            pylab.plot(y3, x3, 'go', label = (y3-cy)>0)
            pylab.axhline(y = x3, c= 'y', ls = '--')
            pylab.plot([y1, y2], [x1, x2], 'r+')
            pylab.subplot(2,2,2)
            pylab.plot(self.rotation(x3, y3, rot)[1], self.rotation(x3, y3, rot)[0], 'go')
            pylab.plot(self.rotation(cx, cy, rot)[1], self.rotation(cx, cy, rot)[0], 'ro')
            pylab.plot([self.rotation(x1, y1, rot)[1], self.rotation(x2, y2, rot)[1]], [self.rotation(x1, y1, rot)[0], self.rotation(x2, y2, rot)[0]], 'r+')
            pylab.xlim([-50., 50.])
            pylab.ylim([-50., 50.])
        return rot, [(x1,y1), (x2,y2), (x3,y3), (int((x3+cx)/2.), int((y3+cy)/2.))]
项目:livespin    作者:biocompibens    | 项目源码 | 文件源码
def plotParams(self, th_sigma_high, th_weight_low, size, title = ''):
        colors = ['r', 'y', 'g', 'c', 'm', 'b']
        paramNames = ['Weight', 'CenterX', 'CenterY', 'SigmaX', 'SigmaY']
        low_lims = [th_weight_low, 0, 0, 0,0]
        high_lims = [None, size, size, th_sigma_high, th_sigma_high]
        fig1 = pylab.figure(figsize = (15,15))
        parameters2, parameters3 = [], []
        for i in xrange(self.lengthSeq):
            for obj in self.listObj[i]:
                if obj.nComponents == 2:
                    parameters2.extend(obj.params)
                elif obj.nComponents == 3:
                    parameters3.extend(obj.params)
        for nParam in range(5):
            pylab.subplot(3,2,nParam+1)
            pylab.plot(range(self.lengthSeq), np.abs(parameters2[nParam::12]), 'b-')
            pylab.plot(range(self.lengthSeq), np.abs(parameters2[6+nParam::12]), 'm-')
            pylab.axhline(y = low_lims[nParam], color = 'r', ls = '-', lw = 5)
            if high_lims[nParam] != 0:
                pylab.axhline(y = high_lims[nParam], color = 'r', ls = '-', lw = 5)
            pylab.title(paramNames[nParam])
        pylab.savefig("{0}_params2.png".format(title))
        pylab.close()
        fig1 = pylab.figure(figsize = (20,15))
        for nParam in range(5):
            pylab.subplot(3,2,nParam+1)
            pylab.plot(range(self.lengthSeq), np.abs(parameters3[nParam::18]), 'b-')
            pylab.plot(range(self.lengthSeq), np.abs(parameters3[6+nParam::18]), 'm-')
            pylab.plot(range(self.lengthSeq), np.abs(parameters3[12+nParam::18]), 'g-')
            pylab.axhline(y = low_lims[nParam], color = 'r', ls = '-', lw = 5)
            if high_lims[nParam] != 0:
                pylab.axhline(y = high_lims[nParam], color = 'r', ls = '-', lw = 5)
            pylab.title(paramNames[nParam])
        pylab.savefig("{0}_params3.png".format(title))
        pylab.close()