• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python numerix.arange函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __call__

    def __call__(self):
        'Return the locations of the ticks'
        self.verify_intervals()
        b=self._base

        vmin, vmax = self.viewInterval.get_bounds()
        vmin = math.log(vmin)/math.log(b)
        vmax = math.log(vmax)/math.log(b)

        if vmax<vmin:
            vmin, vmax = vmax, vmin
        ticklocs = []

        numdec = math.floor(vmax)-math.ceil(vmin)
        if self._subs is None: # autosub
            if numdec>10: subs = array([1.0])
            elif numdec>6: subs = arange(2.0, b, 2.0)
            else: subs = arange(2.0, b)
        else:
            subs = self._subs
        for decadeStart in b**arange(math.floor(vmin),math.ceil(vmax)):
            ticklocs.extend( subs*decadeStart )

        if(len(subs) and subs[0]==1.0):
            ticklocs.append(b**math.ceil(vmax))


        ticklocs = array(ticklocs)
        ind = nonzero(logical_and(ticklocs>=b**vmin ,
                                  ticklocs<=b**vmax))


        ticklocs = take(ticklocs,ind)
        return ticklocs
开发者ID:pv,项目名称:matplotlib-cvs,代码行数:34,代码来源:ticker.py


示例2: filled_regions

def filled_regions(epsoutfile):
    x = arange(0.0, 10.0, 0.1)
    phi = arange(0.0, 2.0*pi, 0.1)
    x_circ = cos(phi)-1.5
    y_circ = sin(phi)-1.0

    x_ell = 1.5*cos(phi)+1.0
    y_ell = 0.5*sin(phi)+0.5

    g=pyxgraph(xlabel=r"$x$", ylabel=r"$y$", xlimits=(-3.0, 3.0),
               ylimits=(-4.0, 4.0), key=False)      
    g.pyxplot((x, -sin(x)-1.0), style="p", title=None)  # we need at least one plot!!
                                                   # even if invisible
    p1 = convert_to_path(g, x_circ, y_circ)
    g.stroke(p1, [pyx.deco.filled([pyx.color.rgb(0.8, 0.8, 0.8)])])

    p2 = convert_to_path(g, x_ell, y_ell)
    g.stroke(p2, [pyx.deco.stroked([pyx.color.rgb(0.8, 0.2, 0.0)]),
                 pyx.style.linewidth(0.35),
                 pyx.deco.filled([pyx.color.rgb(0.8, 0.8, 0.8)]),
                 ])

    # a more funny shape
    p3 = convert_to_path(g, phi/2.0/pi*x_ell-2.4, 3*y_ell+0.5)
    g.fill(p3, [pyx.deco.filled([pyx.color.rgb(0.2, 0.8, 0.2)]),
                 ])

    g.pyxsave(epsoutfile)
开发者ID:deprecated,项目名称:pyxgraph,代码行数:28,代码来源:filled_regions.py


示例3: colorbars

def colorbars(epsoutfile):
    x = (arange(50.0)-25)/2.0
    y = (arange(50.0)-25)/2.0
    r = sqrt(x[:,NewAxis]**2+y**2)
    z = 5.0*cos(r)  

    colmap = ColMapper.ColorMapper("yellow-red", exponent=0.55, brightness=0.5)
    lut = colmap.generate_lut()

    c = pyx.canvas.canvas()
    g = pyxgraph(xlimits=(min(x), max(x)), ylimits=(min(y), max(y)),
                 width=6, height=6)
    g.pyxplot("y(x)=sin(x)", style="p")  # FIXME: can't do empty plots!
    g.pyxplotarray(z, colmap=lut)
    c.insert(g)

    minz = minvalue=min(ravel(z))
    maxz = maxvalue=max(ravel(z))

    # --- vertical bars
    dist = 1.2
    for orientation, position in [("vertical", "right"),
                                  ("vertical", "middle"),
                                  ("vertical2", "middle")]:
        cb = pyxcolorbar(lut=lut, frame=g,
                         pos=(dist, 0),
                         orientation = orientation,
                         position = position,
                         minvalue = minz, maxvalue=maxz)
        # add a short note on the style:
        txt = orientation[0]
        if "2" in orientation:
            txt += "2"
        txt += ", "+position[0]            
        cb.pyxlabel( (0.0, 1.3), txt, style=[pyx.text.halign.left])

        c.insert(cb)
        dist = dist + 0.5

    # horizontal ones:
    dist = -0.3
    for orientation, position in [("horizontal", "middle"),
                                  ("horizontal2", "middle")]:
        cb = pyxcolorbar(lut=lut, frame=g, pos=(0.0, dist),
                         orientation = orientation,
                         position = position,
                         minvalue = minz, maxvalue=maxz)
        # add a short note on the style:
        txt = orientation[0]
        if "2" in orientation:
            txt += "2"
        txt += ", "+position[0]            
        cb.pyxlabel( (1.3, 0.5), txt, style=[pyx.text.halign.left])

        c.insert(cb)
        dist = dist - 0.3
    
    pyxsave(c, epsoutfile)
开发者ID:deprecated,项目名称:pyxgraph,代码行数:58,代码来源:colorbars.py


示例4: array_example1

def array_example1(epsoutfile):
    x = (arange(100.0)-50)/25.0
    y = (arange(100.0)-50)/25.0
    # Important: z[y, x] -- y first!
    z = 5.0*sin(2*x[NewAxis, :]) + 3.0*cos(3*y[:, NewAxis])

    g=pyxgraph(xlimits=(min(x), max(x)), ylimits=(min(y), max(y)),
               width=6, height=6, key=False)
    g.pyxplotcontour(z, x, y, levels=15, colors='map',
                     colmap=ColMapper.ColorMapper("pm3d",
                                                exponent=1.0, brightness=0.2))
    g.pyxsave(epsoutfile)
开发者ID:deprecated,项目名称:pyxgraph,代码行数:12,代码来源:array4.py


示例5: array_example1

def array_example1(epsoutfile):
    x = (arange(50.0)-25)/2.0
    y = (arange(50.0)-25)/2.0
    r = sqrt(x[:,NewAxis]**2+y**2)
    z = 5.0*sin(r)  

    g=pyxgraph(xlimits=(min(x), max(x)), ylimits=(min(y), max(y)),
               width=6, height=6, key=False)
    # WARNING: if key is not specified to be False, one gets a weird
    # error ....
    #g.pyxplot("y(x)=sin(x)", style="p")  # FIXME: can't do empty plots!
    g.pyxplotarray(z, colmap=ColMapper.ColorMapper("yellow-red",
                                                exponent=0.55, brightness=0.5))
    g.pyxsave(epsoutfile)
开发者ID:deprecated,项目名称:pyxgraph,代码行数:14,代码来源:array1.py


示例6: array_example2

def array_example2(epsoutfile):
    x = (arange(100.0)-50)/25.0
    y = (arange(100.0)-50)/25.0
    # Important: z[y, x] -- y first!
    z = 5.0*sin(2*x[NewAxis, :]) + 3.0*cos(3*y[:, NewAxis])

    colmap = ColMapper.ColorMapper("yellow-red", invert=1, exponent=0.55,
                                   brightness=0.5)
    #lut = colmap.generate_lut()

#    c = pyx.canvas.canvas()
    g = pyxgraph(xlimits=(min(x), max(x)), ylimits=(min(y), max(y)),
                 width=6, height=6, key=False)
    g.pyxplotarray(z[::-1,:], colmap=colmap)
    g.pyxplotcontour(z, x, y, colors='color', color='black', labels=True)
   
    pyxsave(g, epsoutfile)
开发者ID:deprecated,项目名称:pyxgraph,代码行数:17,代码来源:array5.py


示例7: drange

def drange(dstart, dend, delta):
    """
    Return a date range as float gregorian ordinals.  dstart and dend
    are datetime instances.  delta is a datetime.timedelta instance
    """
    step = delta.days + delta.seconds/SECONDS_PER_DAY + delta.microseconds/MUSECONDS_PER_DAY
    f1 = _to_ordinalf(dstart)
    f2 = _to_ordinalf(dend)
    return arange(f1, f2, step)
开发者ID:pv,项目名称:matplotlib-cvs,代码行数:9,代码来源:dates.py


示例8: contour_nogrid

def contour_nogrid(z, levels):
    '''calculate the contours of z on a rectangular, equispaced grid at levels.

    z[y, x] holds the value of some scalar function on that
    grid. y and x are taken equispaced with a step length of 1.
    
    levels is a list of float values for which the contours shall be
    calculated.

    Returns a list of equal length to levels. Each entry is a set of contour
    lines for the corresponding level value.

    A set of contour lines is a list which contains 2-element lists
    [xarr, yarr]. xarr and yarr hold the points of one contour line in cartesic
    coordinates.
    
    xarr = result[levidx][lineidx][0]
    yarr = result[levidx][lineidx][1]'''
    return contour_rectgrid(arange(z.shape[1]), arange(z.shape[0]), z, levels)
开发者ID:deprecated,项目名称:pyxgraph,代码行数:19,代码来源:contour.py


示例9: array_example3

def array_example3(epsoutfile):
    x = (arange(200.0) - 100) / 10.0
    y = (arange(200.0) - 100) / 10.0
    r = sqrt(x[:, NewAxis] ** 2 + y ** 2)
    z = 5.0 * cos(r)

    colmap1 = ColMapper.ColorMapper("red")
    colmap1.exponent = 0.9
    colmap1.invert = True

    colmap2 = ColMapper.ColorMapper("green")
    colmap2.exponent = 0.9

    colmap3 = ColMapper.ColorMapper("green")
    colmap3.invert = True
    colmap3.exponent = 0.9

    colmap4 = ColMapper.ColorMapper("blue")
    colmap4.exponent = 0.9

    colmap = ColMapper.SegmentedColorMapping(
        [(-5.0, -2.5, colmap1), (-2.5, 0.0, colmap2), (0.0, 2.5, colmap3), (2.5, 5.0, colmap4)], -5.0, 5.0
    )

    #     colmap = ColMapper.example_SegmentedColorMapping(min(ravel(z)),max(ravel(z)))
    lut = colmap.generate_lut()

    pilbitmap = ColMapper.Array2PIL(z, lut=lut)

    c = pyx.canvas.canvas()
    g = pyxgraph(xlimits=(min(x), max(x)), ylimits=(min(y), max(y)), width=6, height=6, key=False)
    g.pyxplot("y(x)=sin(x)+20", style="p")  # FIXME: can't do empty plots!

    g.pyxbitmap(pilbitmap)

    c.insert(g)

    cb = pyxcolorbar(lut=lut, frame=g, pos=(1.1, 0.0), minvalue=min(ravel(z)), maxvalue=max(ravel(z)))
    c.insert(cb)

    pyxsave(c, epsoutfile)
开发者ID:deprecated,项目名称:pyxgraph,代码行数:41,代码来源:array3.py


示例10: styles_example2

def styles_example2(epsoutfile):
    x = arange(2.0, 10.0, 0.1)
    y = 0.0 * x
    y[::2] = 1.0

    g = pyxgraph(xlimits=(0, 10), ylimits=(-1, 6), key=None, width=8)

    # lines for comparison:
    x2 = arange(0.0, 5.0, 0.1)
    for i in xrange(6):
        g.pyxplot((x2, 0 * x2 + i), color=(0.6, 0.6, 0.6), style="l", lt=0, lw=0.25)

    g.pyxplot((x, y), style="l", lt=0)  # pyx.style.linejoin.meter is default
    g.pyxplot((x, y + 2), style="l", lt=0, lineattrs=[pyx.style.linejoin.bevel])
    g.pyxplot((x, y + 4), style="l", lt=0, lineattrs=[pyx.style.linejoin.round])

    txtstyle = [pyx.text.halign.left, pyx.text.valign.middle]
    g.pyxlabel((0.5, 0.5), "miter", txtstyle, graphcoords=True)
    g.pyxlabel((0.5, 2.5), "bevel", txtstyle, graphcoords=True)
    g.pyxlabel((0.5, 4.5), "round", txtstyle, graphcoords=True)
    g.pyxsave(epsoutfile)
开发者ID:deprecated,项目名称:pyxgraph,代码行数:21,代码来源:styles_example2.py


示例11: array_example2

def array_example2(epsoutfile):
    x = (arange(50.0)-25)/2.0
    y = (arange(50.0)-25)/2.0
    r = sqrt(x[:,NewAxis]**2+y**2)
    z = 5.0*cos(r)  

    colmap = ColMapper.ColorMapper("yellow-red", exponent=0.55, brightness=0.5)
    lut = colmap.generate_lut()

    c = pyx.canvas.canvas()
    g = pyxgraph(xlimits=(min(x), max(x)), ylimits=(min(y), max(y)),
                 width=6, height=6)
    g.pyxplot("y(x)=sin(x)", style="p")  # FIXME: can't do empty plots!
    g.pyxplotarray(z, colmap=lut)
    c.insert(g)

    cb = pyxcolorbar(lut=lut, frame=g, pos=(1.1,0.0),
                     minvalue=min(ravel(z)), maxvalue=max(ravel(z)))
    c.insert(cb)
    
    pyxsave(c, epsoutfile)
开发者ID:deprecated,项目名称:pyxgraph,代码行数:21,代码来源:array2.py


示例12: symbols

def symbols(epsoutfile):
    y = arange(5)/5.0+0.1
    
    g = pyxgraph(xlimits=(-1, 25), ylimits=(0, 1),           
                 xticks=(0, 24, 2), yticks=(0, 1, 1), key=None) 
    
    for i in xrange(25):
        x = zeros(5)+i   
        g.pyxplot((x, y), style="p", pt=i)   # ``pt=i`` can be omitted
                                             # (then the next symbol is choosen
                                             #  automatically)
    g.pyxsave(epsoutfile)
开发者ID:deprecated,项目名称:pyxgraph,代码行数:12,代码来源:symbols.py


示例13: makeMappingArray

def makeMappingArray(N, data):
    """Create an N-element 1-d lookup table

    data represented by a list of x,y0,y1 mapping correspondences.
    Each element in this list represents how a value between 0 and 1
    (inclusive) represented by x is mapped to a corresponding value
    between 0 and 1 (inclusive). The two values of y are to allow
    for discontinuous mapping functions (say as might be found in a
    sawtooth) where y0 represents the value of y for values of x
    <= to that given, and y1 is the value to be used for x > than
    that given). The list must start with x=0, end with x=1, and
    all values of x must be in increasing order. Values between
    the given mapping points are determined by simple linear interpolation.

    The function returns an array "result" where result[x*(N-1)]
    gives the closest value for values of x between 0 and 1.
    """
    try:
        adata = array(data)
    except:
        raise TypeError("data must be convertable to an array")
    shape = adata.shape
    if len(shape) != 2 and shape[1] != 3:
        raise ValueError("data must be nx3 format")

    x  = adata[:,0]
    y0 = adata[:,1]
    y1 = adata[:,2]

    if x[0] != 0. or x[-1] != 1.0:
        raise ValueError(
           "data mapping points must start with x=0. and end with x=1")
    if sometrue(sort(x)-x):
        raise ValueError(
           "data mapping points must have x in increasing order")
    # begin generation of lookup table
    x = x * (N-1)
    lut = zeros((N,), Float)
    xind = arange(float(N))
    ind = searchsorted(x, xind)[1:-1]

    lut[1:-1] = ( divide(xind[1:-1] - take(x,ind-1),
                         take(x,ind)-take(x,ind-1) )
                  *(take(y0,ind)-take(y1,ind-1)) + take(y1,ind-1))
    lut[0] = y1[0]
    lut[-1] = y0[-1]
    # ensure that the lut is confined to values between 0 and 1 by clipping it
    clip(lut, 0.0, 1.0)
    #lut = where(lut > 1., 1., lut)
    #lut = where(lut < 0., 0., lut)
    return lut
开发者ID:florisvb,项目名称:floris_functions,代码行数:51,代码来源:converting_colornames.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python numerix.array函数代码示例发布时间:2022-05-27
下一篇:
Python numerix.absolute函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap