当前位置: 首页>>代码示例>>Python>>正文


Python biggles.FramedPlot类代码示例

本文整理汇总了Python中biggles.FramedPlot的典型用法代码示例。如果您正苦于以下问题:Python FramedPlot类的具体用法?Python FramedPlot怎么用?Python FramedPlot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FramedPlot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plotrand

def plotrand(x, y, frac=0.1, plt=None, **keys):
    import biggles
    from biggles import FramedPlot, Points
    if plt is None:
        plt = FramedPlot()

    x=numpy.array(x,ndmin=1,copy=False)
    y=numpy.array(y,ndmin=1,copy=False)
    if x.size != y.size:
        raise ValueError("x,y must be same size")
    nrand = int(x.size*frac)

    ind = numpy_util.random_subset(x.size, nrand)

    if 'type' not in keys:
        keys['type'] = 'dot'

    c = Points(x[ind], y[ind], **keys)
    plt.add(c)

    if 'xlabel' in keys:
        plt.xlabel = keys['xlabel']
    if 'ylabel' in keys:
        plt.ylabel = keys['ylabel']


    show = keys.get('show',True)
    if show:
        plt.show()

    return plt
开发者ID:d80b2t,项目名称:python,代码行数:31,代码来源:plotting.py

示例2: plotprimedens

def plotprimedens(n):
    pd = primedens(n)
    steps = range(len(pd))
    from biggles import FramedPlot, Curve
    g = FramedPlot()
    g.add(Curve(steps,pd))
    g.show()
    return
开发者ID:neffmallon,项目名称:pistol,代码行数:8,代码来源:perfect.py

示例3: plot_radec

    def plot_radec(self, type):
        """
        ra/dec plot of all points and the matched points
        """
        import biggles
        import converter
        from biggles import FramedPlot,Points

        print()
        dir=self.plotdir()
        if not os.path.exists(dir):
            os.makedirs(dir)

        psfile = self.plotfile(type)

        orig = self.read_original(type)
        mat = self.read_matched(type)

        plt=FramedPlot() 

        symsize = 2
        if type == 'sdss' or type == 'other':
            symsize = 0.25

        plt.add( Points(orig['ra'],orig['dec'],type='dot', size=symsize) )

        plt.add( Points(mat['ra'],mat['dec'],type='dot',
                        color='red', size=symsize) )
        plt.xlabel = 'RA'
        plt.ylabel = 'DEC'
        print("Writing eps file:", psfile)
        plt.write_eps(psfile)
        converter.convert(psfile, dpi=120, verbose=True)
开发者ID:esheldon,项目名称:espy,代码行数:33,代码来源:training.py

示例4: plot_masserr

    def plot_masserr(self, filename):
        import pcolors
        data=eu.io.read(filename)
        nr200 = data.size
        nb = data['B'][0].size

        plt = FramedPlot()
        colors = pcolors.rainbow(nr200, 'hex')
        clist = []
        for ri in xrange(nr200):
            r200 = data['r200'][ri]
            m200 = data['m200'][ri]

            p = Points(data['B'][ri], (m200-data['m200meas'][ri])/m200, 
                       type='filled circle', color=colors[ri])
            crv = Curve(data['B'][ri], (m200-data['m200meas'][ri])/m200, 
                        color=colors[ri])
            crv.label = 'r200: %0.2f' % r200
            clist.append(crv)
            plt.add(p,crv)

        key = PlotKey(0.1,0.4,clist)
        plt.add(key)
        plt.xlabel=r'$\Omega_m \sigma_8^2 D(z)^2 b(M,z)$'
        plt.ylabel = r'$(M_{200}^{true}-M)/M_{200}^{true}$'

        epsfile = filename.replace('.rec','.eps')
        print 'writing eps:',epsfile
        plt.write_eps(eu.ostools.expand_path(epsfile))
开发者ID:esheldon,项目名称:espy,代码行数:29,代码来源:invert.py

示例5: plot_pk

    def plot_pk(self,k,pk):
        from biggles import FramedPlot, Curve

        plt=FramedPlot()
        plt.add(Curve(k,pk))
        plt.xlog=True
        plt.ylog=True

        plt.xlabel = r'$k [h/Mpc]$'
        plt.ylabel = r'$P_{lin}(k)$'
        plt.aspect_ratio = 1
        plt.show()
开发者ID:esheldon,项目名称:espy,代码行数:12,代码来源:linear.py

示例6: plot_xi

    def plot_xi(self, r, xi):
        from biggles import FramedPlot, Curve
        minval = 1.e-4

        xi = where(xi < minval, minval, xi)

        plt=FramedPlot()
        plt.add(Curve(r,xi))
        plt.xlog=True
        plt.ylog=True

        plt.xlabel = r'$r [Mpc/h]$'
        plt.ylabel = r'$\xi_{lin}(r)$'
        plt.aspect_ratio=1
        plt.show()
开发者ID:esheldon,项目名称:espy,代码行数:15,代码来源:linear.py

示例7: doplot

    def doplot(self, fitres, h, minmag, maxmag):
        tab=biggles.Table(2,1)

        plt=FramedPlot()
        plt.title='%s %.2f %.2f ' % (self.objtype, minmag, maxmag)
        plt.xlabel=r'$\sigma$'

        sprior=fitres.get_model()

        nrand=100000
        binsize=self.binsize

        hplt=Histogram(h['hist'], x0=h['low'][0], binsize=binsize)
        hplt.label='data'

        srand=sprior.sample(nrand)
        hrand=histogram(srand, binsize=binsize, min=h['low'][0], max=h['high'][-1], more=True)
        hrand['hist'] = hrand['hist']*float(h['hist'].sum())/nrand

        hpltrand=Histogram(hrand['hist'], x0=hrand['low'][0], binsize=binsize,
                           color='blue')
        hpltrand.label='rand'


        key=PlotKey(0.9,0.9,[hplt,hpltrand],halign='right')

        plt.add(hplt, hpltrand, key)

        
        tplt=fitres.plot_trials(show=False,fontsize_min=0.88888888)
        
        tab[0,0] = plt
        tab[1,0] = tplt

        if self.show:
            tab.show()

        d=files.get_prior_dir()
        d=os.path.join(d, 'plots')
        epsfile='pofs-%.2f-%.2f-%s.eps' % (minmag,maxmag,self.objtype)
        epsfile=os.path.join(d,epsfile)
        eu.ostools.makedirs_fromfile(epsfile)
        print epsfile
        tab.write_eps(epsfile)
        os.system('converter -d 100 %s' % epsfile)

        return tab
开发者ID:esheldon,项目名称:espy,代码行数:47,代码来源:fit-sprior-true.py

示例8: doplot

    def doplot(self):
        tab = Table(2, 1)
        tab.title = self.title

        xfit, yfit, gprior = self.get_prior_vals()

        nrand = 100000
        binsize = self.binsize
        h = self.h
        h1 = self.h1
        h2 = self.h2

        g1rand, g2rand = gprior.sample2d(nrand)
        grand = gprior.sample1d(nrand)

        hrand = histogram(grand, binsize=binsize, min=0.0, max=1.0, more=True)
        h1rand = histogram(g1rand, binsize=binsize, min=-1.0, max=1.0, more=True)

        fbinsize = xfit[1] - xfit[0]
        hrand["hist"] = hrand["hist"] * float(yfit.sum()) / hrand["hist"].sum() * fbinsize / binsize
        h1rand["hist"] = h1rand["hist"] * float(h1["hist"].sum()) / h1rand["hist"].sum()

        pltboth = FramedPlot()
        pltboth.xlabel = r"$g$"

        hplt1 = Histogram(h1["hist"], x0=h1["low"][0], binsize=binsize, color="red")
        hplt2 = Histogram(h2["hist"], x0=h2["low"][0], binsize=binsize, color="blue")
        hpltrand = Histogram(hrand["hist"], x0=hrand["low"][0], binsize=binsize, color="magenta")
        hplt1rand = Histogram(h1rand["hist"], x0=h1rand["low"][0], binsize=binsize, color="magenta")

        hplt1.label = r"$g_1$"
        hplt2.label = r"$g_2$"
        hplt1rand.label = "rand"
        hpltrand.label = "rand"
        keyboth = PlotKey(0.9, 0.9, [hplt1, hplt2, hplt1rand], halign="right")

        pltboth.add(hplt1, hplt2, hplt1rand, keyboth)
        tab[0, 0] = pltboth

        plt = FramedPlot()
        plt.xlabel = r"$|g|$"

        hplt = Histogram(h["hist"], x0=h["low"][0], binsize=binsize)
        hplt.label = "|g|"

        line = Curve(xfit, yfit, color="blue")
        line.label = "model"

        key = PlotKey(0.9, 0.9, [hplt, line, hpltrand], halign="right")
        plt.add(line, hplt, hpltrand, key)

        tab[1, 0] = plt

        if self.show:
            tab.show()

        return tab
开发者ID:esheldon,项目名称:espy,代码行数:57,代码来源:fit-prior.py

示例9: test_rainbow

def test_rainbow():
    import numpy
    from biggles import FramedPlot, Points, Curve
    num = 20

    plt = FramedPlot()

    x = numpy.linspace(0.0, 1.0, num)
    y = x**2

    colors = rainbow(num, 'hex')

    for i in xrange(num):
        p = Points([x[i]], [y[i]], type='filled circle', 
                   color=colors[i])
        c = Curve([x[i]],[y[i]], color=colors[i])
        plt.add(p,c)
    plt.show()
开发者ID:esheldon,项目名称:espy,代码行数:18,代码来源:pcolors.py

示例10: plot_drho

def plot_drho(comb=None, r=None, drho=None, drhoerr=None, 
              color='black',type='filled circle',
              nolabel=False, noshow=False, minval=1.e-5,
              aspect_ratio=1):
    """
    This one stands alone. 
    """

    if comb is not None:
        r=comb['rdrho']
        drho=comb['drho']
        drhoerr=comb['drhoerr']
    else:
        if r is None or drho is None or drhoerr is None:
            raise ValueError("Send a combined struct or r,drho,drhoerr")


    plt=FramedPlot()
    plt.aspect_ratio=aspect_ratio
    plt.xlog=True
    plt.ylog=True

    if not nolabel:
        plt.xlabel = r'$r$ [$h^{-1}$ Mpc]'
        plt.ylabel = r'$\delta\rho ~ [M_{\odot} pc^{-3}]$'


    od=add_to_log_plot(plt, r, drho, drhoerr, 
                       color=color, 
                       type=type,
                       minval=minval)

    # for drho we need even broader yrange
    plt.xrange = od['xrange']

    yr=od['yrange']
    plt.yrange = [0.5*yr[0], 3*yr[1]]

    if not noshow:
        plt.show()
    od['plt'] = plt
    return od
开发者ID:esheldon,项目名称:espy,代码行数:42,代码来源:plotting.py

示例11: compare_all_other

    def compare_all_other(self, type, show=True):
        
        fdict=self.all_other_fdict(type)

        # this is the original file.  It has the redshifts
        orig = zphot.weighting.read_training(fdict['origfile'])

        # this is the outputs
        num = zphot.weighting.read_num(fdict['numfile1'])

        # this is the weights file
        weights = zphot.weighting.read_training(fdict['wfile2'])

        # recoverable set
        w_recoverable = where1(num['num'] > 0)
        # this is actually the indexes back into the "orig" file
        w_keep = num['photoid'][w_recoverable]

        # get the z values for these validation objects
        zrec = orig['z'][w_keep]

        binsize=0.0314
        valid_dict = histogram(zrec, min=0, max=1.1, binsize=binsize, more=True)
        plt=FramedPlot()

        vhist = valid_dict['hist']/(float(valid_dict['hist'].sum()))
        pvhist=biggles.Histogram(vhist, x0=valid_dict['low'][0], binsize=binsize)
        pvhist.label = 'truth'

        weights_dict = histogram(weights['z'], min=0, max=1.1, binsize=binsize,
                                 weights=weights['weight'], more=True)
        whist = weights_dict['whist']/weights_dict['whist'].sum()
        pwhist=biggles.Histogram(whist, x0=weights_dict['low'][0], 
                                 binsize=binsize, color='red')
        pwhist.label = 'weighted train'

        key = PlotKey(0.6,0.6,[pvhist,pwhist])
        plt.add(pvhist,pwhist,key)

        plt.add( biggles.PlotLabel(.8, .9, type) )

        plt.write_eps(fdict['zhistfile'])
        converter.convert(fdict['zhistfile'],dpi=90,verbose=True)
        if show:
            plt.show()
开发者ID:esheldon,项目名称:espy,代码行数:45,代码来源:validation.py

示例12: plot_m

    def plot_m(self, r200, c):
        from biggles import FramedPlot, Curve
        n=1000
        r = numpy.linspace(0.01, 20.0,n)
        m = self.m(r, r200, c)

        plt=FramedPlot()
        plt.add( Curve(r,m) )
        plt.xlog=True
        plt.ylog=True

        plt.show()
开发者ID:esheldon,项目名称:espy,代码行数:12,代码来源:nfw.py

示例13: plot_mass

def plot_mass(comb=None, r=None, mass=None, masserr=None, 
              color='black',type='filled circle',
              nolabel=False, noshow=False, minval=1.e11,
              aspect_ratio=1):

    if comb is not None:
        r=comb['rmass']
        mass=comb['mass']
        masserr=comb['masserr']
    else:
        if r is None or mass is None or masserr is None:
            raise ValueError("Send a combined struct or r,mass,masserr")


    plt=FramedPlot()
    plt.aspect_ratio=aspect_ratio
    plt.xlog=True
    plt.ylog=True

    if not nolabel:
        plt.xlabel = r'$r$ [$h^{-1}$ Mpc]'
        plt.ylabel = r'$M(<r) ~ [h^{-1} M_{\odot}]$'


    od=add_to_log_plot(plt, r, mass, masserr, 
                       color=color, 
                       type=type,
                       minval=minval)

    plt.xrange = od['xrange']
    plt.yrange = od['yrange']

    if not noshow:
        plt.show()
    od['plt'] = plt
    return od
开发者ID:esheldon,项目名称:espy,代码行数:36,代码来源:plotting.py

示例14: plot_fits

    def plot_fits(self, st):
        import biggles

        biggles.configure("default", "fontsize_min", 2)
        parnames = ["A", "a", "g0", "gmax"]

        npars = len(parnames)
        tab = Table(npars, 1)

        magmiddle = (st["minmag"] + st["maxmag"]) / 2
        for i in xrange(npars):

            yval = st["pars"][:, i]
            yerr = st["perr"][:, i]

            ymean = yval.mean()
            ystd = yval.std()
            yrange = [ymean - 3.5 * ystd, ymean + 3.5 * ystd]

            pts = Points(magmiddle, yval, type="filled circle")
            yerrpts = SymmetricErrorBarsY(magmiddle, yval, yerr)
            xerrpts = ErrorBarsX(yval, st["minmag"], st["maxmag"])

            plt = FramedPlot()
            plt.yrange = yrange
            plt.add(pts, xerrpts, yerrpts)
            plt.xlabel = "mag"
            plt.ylabel = parnames[i]

            tab[i, 0] = plt

        if self.show:
            tab.show()

        d = files.get_prior_dir()
        d = os.path.join(d, "plots")
        epsfile = "pofe-pars-%s.eps" % self.otype
        epsfile = os.path.join(d, epsfile)
        eu.ostools.makedirs_fromfile(epsfile)
        print epsfile
        tab.write_eps(epsfile)
        os.system("converter -d 100 %s" % epsfile)
开发者ID:esheldon,项目名称:espy,代码行数:42,代码来源:fit-prior-gmix-eta.py

示例15: testfit

def testfit():
    import biggles 
    from biggles import FramedPlot,Points,Curve
    import scipy
    from scipy.optimize import leastsq

    ## Parametric function: 'v' is the parameter vector, 'x' the independent varible
    fp = lambda v, x: v[0]/(x**v[1])*sin(v[2]*x)

    ## Noisy function (used to generate data to fit)
    v_real = [1.5, 0.1, 2.]
    fn = lambda x: fp(v_real, x)

    ## Error function
    e = lambda v, x, y: (fp(v,x)-y)

    ## Generating noisy data to fit
    n = 30
    xmin = 0.1
    xmax = 5
    x = linspace(xmin,xmax,n)
    y = fn(x) + scipy.rand(len(x))*0.2*(fn(x).max()-fn(x).min())

    ## Initial parameter value
    v0 = [3., 1, 4.]

    ## Fitting
    v, success = leastsq(e, v0, args=(x,y), maxfev=10000)

    print('Estimater parameters: ', v)
    print('Real parameters: ', v_real)
    X = linspace(xmin,xmax,n*5)
    plt=FramedPlot()
    plt.add(Points(x,y))
    plt.add(Curve(X,fp(v,X),color='red'))

    plt.show()
开发者ID:esheldon,项目名称:admom,代码行数:37,代码来源:admom_test.py


注:本文中的biggles.FramedPlot类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。