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

Python numerix.array函数代码示例

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

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



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

示例1: set_data

    def set_data(self, data):
        if data is None:
            self.inputdata = None
            self.chartdata = None
            return

        data = array(data)
        dim = len(shape(data))
        if dim not in (1, 2, 3):
            raise AttributeError, "Input data must be a 1, 2, or 3d matrix"
        self.inputdata = data

        # If the input data is a 1d matrix, then it describes a
        # standard bar chart.
        if dim == 1:
            self.chartdata = array([[data]])

        # If the input data is a 2d matrix, then it describes a bar
        # chart with groups. The matrix being an array of groups of
        # bars.
        if dim == 2:
            self.chartdata = transpose([data], axes=(2, 0, 1))

        # If the input data is a 3d matrix, then it describes an array
        # of groups of bars with each bar being an array of stacked
        # values.
        if dim == 3:
            self.chartdata = transpose(data, axes=(1, 2, 0))
开发者ID:AMDmi3,项目名称:gem5,代码行数:28,代码来源:barchart.py


示例2: plot

    def plot(self):
        win = gtk.Window()
        winBox = gtk.HBox()
        plotBox = gtk.VBox()
        rightBox = gtk.VBox()
        statFrame = gtk.Frame()
        statBox = gtk.VBox()
        winBox.pack_start(plotBox)
        rightBox.pack_start(statFrame, True, False)
        winBox.pack_start(rightBox, False, False)
#        statFrame.add (statBox)
        win.add (winBox)
        fig = Figure(figsize=(5,4), dpi=100)
        ax = fig.add_subplot(111)
        ax.plot(self.x,self.y)
        ax.hold(True)
        xMean = array([0.0, self.y.size()]) 
        yMean = array([self.mean, self.mean])
        h1 = ax.plot(xMean, yMean, 'g', linewidth=2)
        ax.set_title(self.name)
        ax.set_xlabel("block")
        ax.set_ylabel("Energy")
        canvas = FigureCanvas(fig)
        plotBox.pack_start(canvas)
        toolbar = NavigationToolbar(canvas, win)
        plotBox.pack_start(toolbar, False, False)
        # Make statistics box
        statFrame.set_label("Statistics")
        statTable = gtk.Table(3, 2, False)
        statFrame.add(statTable)

        (meanStr, errorStr) = MeanErrorString(self.mean, self.error)
        meanLabel1 = gtk.Label("Mean: ")
        meanLabel2 = gtk.Label(meanStr + " +/- " + errorStr)
        statTable.attach(meanLabel1, 0, 1, 0, 1, gtk.SHRINK)
        statTable.attach(meanLabel2, 1, 2, 0, 1, gtk.SHRINK)

        varStr   = '%1.2f' % self.var
        varLabel1 = gtk.Label("Variance:")
        varLabel2 = gtk.Label(varStr)
        statTable.attach(varLabel1, 0, 1, 1, 2, gtk.SHRINK)
        statTable.attach(varLabel2, 1, 2, 1, 2, gtk.SHRINK)

        kappaStr= '%1.2f' % self.kappa
        kappaLabel1=gtk.Label("Kappa: ")
        kappaLabel2=gtk.Label(kappaStr)
        statTable.attach(kappaLabel1, 0, 1, 2, 3, gtk.SHRINK)
        statTable.attach(kappaLabel2, 1, 2, 2, 3, gtk.SHRINK)
        
        win.set_size_request(650,500)
        win.show_all()
开发者ID:majorana,项目名称:pimcplusplus,代码行数:51,代码来源:ds++.py


示例3: volume_overlay2

def volume_overlay2(ax, closes, volumes,
                   colorup='k', colordown='r',
                   width=4, alpha=1.0):
    """
    Add a volume overlay to the current axes.  The closes are used to
    determine the color of the bar.  -1 is missing.  If a value is
    missing on one it must be missing on all

    ax          : an Axes instance to plot to
    width       : the bar width in points
    colorup     : the color of the lines where close >= open
    colordown   : the color of the lines where close <  open
    alpha       : bar transparency

    nb: first point is not displayed - it is used only for choosing the
    right color

    """

    opens = nx.array(closes[:-1])
    last = 0
    for i in range(0,len(opens)):
        if opens[i] == -1:
            opens[i] = last
        else:
            last = opens[i]

    return volume_overlay(ax,opens,closes[1:],volumes[1:],colorup,colordown,width,alpha)
开发者ID:botvs,项目名称:FinancialAnalytics,代码行数:28,代码来源:myfinance.py


示例4: set_err

    def set_err(self, err):
        if err is None:
            self.inputerr = None
            self.charterr = None
            return

        err = array(err)
        dim = len(shape(err))
        if dim not in (1, 2, 3):
            raise AttributeError, "Input err must be a 1, 2, or 3d matrix"
        self.inputerr = err

        if dim == 1:
            self.charterr = array([[err]])

        if dim == 2:
            self.charterr = transpose([err], axes=(2, 0, 1))

        if dim == 3:
            self.charterr = transpose(err, axes=(1, 2, 0))
开发者ID:AMDmi3,项目名称:gem5,代码行数:20,代码来源:barchart.py


示例5: get_ticker

 def get_ticker(ticker):
     vals = []
     lines = file( '%s' % ticker ).readlines()
     for line in lines[1:]:
         try:
             vals.append([float(val) for val in line.split()[0:]])
         except:
             pass
     M = array(vals)
     c = C()
     c.sma = M[:,0]
     c.flux = M[:,1]
     c.flux_err = M[:,2]
     c.mag = M[:,3]
     c.mag_uerr = M[:,4]
     c.mag_lerr = M[:,5]
     return c
开发者ID:svn2github,项目名称:pymorph,代码行数:17,代码来源:plotfunc.py


示例6: __init__

 def __init__( self, strengthRange, ax, pos, decay_time=2 ) :
     
   n = 25
   t = arange(n)*2*pi/n
   self.disc = array([(cos(x),sin(x)) for x in t])
   self.strength = 0
   self.pos = pos
   self.offset = (279, 157)
   self.scale = 1.35
   self.max_size = 5 #0.5
   self.min_size = 0.10 #0.05
   self.size = self.min_size
   self.color = '#ff8000'
   self.decay_time = decay_time
   self.strengthRange = strengthRange
   self.t0 = 0
   v = self.disc * self.size + self.pos
   self.poly = ax.fill( v[:,0], v[:,1], self.color )
开发者ID:saurabhd14,项目名称:tinyos-1.x,代码行数:18,代码来源:RfsFieldGui.py


示例7: savecsv

    def savecsv(self, name):
        f = file(name, "w")
        data = array(self.inputdata)
        dim = len(data.shape)

        if dim == 1:
            # if self.xlabel:
            #    f.write(', '.join(list(self.xlabel)) + '\n')
            f.write(", ".join(["%f" % val for val in data]) + "\n")
        if dim == 2:
            # if self.xlabel:
            #    f.write(', '.join([''] + list(self.xlabel)) + '\n')
            for i, row in enumerate(data):
                ylabel = []
                # if self.ylabel:
                #    ylabel = [ self.ylabel[i] ]
                f.write(", ".join(ylabel + ["%f" % v for v in row]) + "\n")
        if dim == 3:
            f.write("don't do 3D csv files\n")
            pass

        f.close()
开发者ID:AMDmi3,项目名称:gem5,代码行数:22,代码来源:barchart.py


示例8: graph

    def graph(self, name, graphdir, proxy=None):
        from os.path import expanduser, isdir, join as joinpath
        from barchart import BarChart
        from matplotlib.numerix import Float, array, zeros
        import os, re, urllib
        from jobfile import crossproduct

        confgroups = self.jobfile.groups()
        ngroups = len(confgroups)
        skiplist = [ False ] * ngroups
        groupopts = []
        baropts = []
        groups = []
        for i,group in enumerate(confgroups):
            if group.flags.graph_group:
                groupopts.append(group.subopts())
                skiplist[i] = True
            elif group.flags.graph_bars:
                baropts.append(group.subopts())
                skiplist[i] = True
            else:
                groups.append(group)

        has_group = bool(groupopts)
        if has_group:
            groupopts = [ group for group in crossproduct(groupopts) ]
        else:
            groupopts = [ None ]

        if baropts:
            baropts = [ bar for bar in crossproduct(baropts) ]
        else:
            raise AttributeError, 'No group selected for graph bars'

        directory = expanduser(graphdir)
        if not isdir(directory):
            os.mkdir(directory)
        html = file(joinpath(directory, '%s.html' % name), 'w')
        print >>html, '<html>'
        print >>html, '<title>Graphs for %s</title>' % name
        print >>html, '<body>'
        html.flush()

        for options in self.jobfile.options(groups):
            chart = BarChart(self)

            data = [ [ None ] * len(baropts) for i in xrange(len(groupopts)) ]
            enabled = False
            stacked = 0
            for g,gopt in enumerate(groupopts):
                for b,bopt in enumerate(baropts):
                    if gopt is None:
                        gopt = []
                    job = self.jobfile.job(options + gopt + bopt)
                    if not job:
                        continue

                    if proxy:
                        import db
                        proxy.dict['system'] = self.info[job.system]
                    val = self.info.get(job, self.stat)
                    if val is None:
                        print 'stat "%s" for job "%s" not found' % \
                              (self.stat, job)

                    if isinstance(val, (list, tuple)):
                        if len(val) == 1:
                            val = val[0]
                        else:
                            stacked = len(val)

                    data[g][b] = val

            if stacked == 0:
                for i in xrange(len(groupopts)):
                    for j in xrange(len(baropts)):
                        if data[i][j] is None:
                            data[i][j] = 0.0
            else:
                for i in xrange(len(groupopts)):
                    for j in xrange(len(baropts)):
                        val = data[i][j]
                        if val is None:
                            data[i][j] = [ 0.0 ] * stacked
                        elif len(val) != stacked:
                            raise ValueError, "some stats stacked, some not"

            data = array(data)
            if data.sum() == 0:
                continue

            dim = len(data.shape)
            x = data.shape[0]
            xkeep = [ i for i in xrange(x) if data[i].sum() != 0 ]
            y = data.shape[1]
            ykeep = [ i for i in xrange(y) if data[:,i].sum() != 0 ]
            data = data.take(xkeep, axis=0)
            data = data.take(ykeep, axis=1)
            if not has_group:
                data = data.take([ 0 ], axis=0)
#.........这里部分代码省略.........
开发者ID:AMDmi3,项目名称:gem5,代码行数:101,代码来源:output.py


示例9: zip

that is, a single tuple instead of a list of tuples, to generate
successively offset curves, with the offset given in data
units.  This behavior is available only for the LineCollection.

'''

import pylab as P
from matplotlib import collections, axes, transforms
from matplotlib.colors import colorConverter
import matplotlib.numerix as N

nverts = 50
npts = 100

# Make some spirals
r = N.array(range(nverts))
theta = N.array(range(nverts)) * (2*N.pi)/(nverts-1)
xx = r * N.sin(theta)
yy = r * N.cos(theta)
spiral = zip(xx,yy)

# Make some offsets
xo = P.randn(npts)
yo = P.randn(npts)
xyo = zip(xo, yo)

# Make a list of colors cycling through the rgbcmyk series.
colors = [colorConverter.to_rgba(c) for c in ('r','g','b','c','y','m','k')]

fig = P.figure()
开发者ID:ghorn,项目名称:Eg,代码行数:30,代码来源:collections_demo.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python numerix.fromstring函数代码示例发布时间:2022-05-27
下一篇:
Python numerix.arange函数代码示例发布时间: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