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


Python FigureCanvasWxAgg.print_png方法代码示例

本文整理汇总了Python中matplotlib.backends.backend_wxagg.FigureCanvasWxAgg.print_png方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasWxAgg.print_png方法的具体用法?Python FigureCanvasWxAgg.print_png怎么用?Python FigureCanvasWxAgg.print_png使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.backends.backend_wxagg.FigureCanvasWxAgg的用法示例。


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

示例1: MainFrame

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import print_png [as 别名]

#.........这里部分代码省略.........

    def EvtCheckListBox(self, event):
        """
        EvtCheckListBox is called whenever an item in self.lb is checked
        """
        index = event.GetSelection()
        key = self.lb.GetString(index)

        if self.lb.IsChecked(index):
            self._AddtoChecked(index, key)
        else: 
            self._RemovefromChecked(index, key)

    def xLabel(self, event):
        self.axes.xlabel = self.xLabelCtrl.GetValue()
        self.axes.set_xlabel(self.xLabelCtrl.GetValue())

    def yLabel(self, event):
        self.axes.ylabel = self.yLabelCtrl.GetValue()
        self.axes.set_ylabel(self.yLabelCtrl.GetValue())

    def _AddtoChecked(self, index, key):
            # Add tuple to list
            self.CheckedKeys.append( (index, key) )

    def _RemovefromChecked(self, index, key):
            # Remove tuple from list
            self.CheckedKeys.pop( self.CheckedKeys.index( (index,key) ) )

    def ClearSelection(self, e):
        self.CheckedKeys = []
        for n in xrange(self.lb.GetCount()): self.lb.Check(n, check=False)

    def SelectAll(self, e):
        self.CheckedKeys = self.RegExKeys
        for n in xrange(self.lb.GetCount()): self.lb.Check(n, check=True)

    def ToggleSelection(self, e):
        for n in xrange( self.lb.GetCount() ):
            if self.lb.IsChecked(n): 
                check = False
                self._RemovefromChecked( n, self.lb.GetString(n) )
            else: 
                check = True
                self._AddtoChecked( n, self.lb.GetString(n) )
            self.lb.Check(n, check=check)
    
    def _AnimateEvent(self, event):

        self.CheckedKeys.sort()
        AD = AnimateDialog(self, -1, "Animate")
        AD.Centre()

        val = AD.ShowModal()
        if val == wx.ID_OK:
            self.Animate(AD.filename, AD.directory)
        AD.Destroy()

    def Plot(self, key, title=None):
        """
        Plot will plot the data from self.gF.Data[key] in self.canvas
        """
        x = numpy.transpose( self.gF.Data[key] )
        index = self.plotStyle.GetCurrentSelection()
        style = self.plotStyle.GetString(index)
        
        if style == 'steps':
            self.axes.plot(x[0], x[1], ls='steps')
        elif style == 'errorbars':
            try:
                self.axes.errorbar(x[0],x[1],x[2])
            except IndexError:
                print "You must have errorbar data in your input file"
        elif style ==  'lines':
            self.axes.plot(x[0],x[1], '-')
        elif style == 'linespoints':
            self.axes.plot(x[0],x[1], '.-')
        elif style == 'points':
            self.axes.plot(x[0],x[1], '.')
        else: raise KeyError, "I don't know how to plot that style, yet"

        if not title:   
            self.axes.set_title(self.titleCtrl.GetValue())
        self.axes.set_xlabel(self.xLabelCtrl.GetValue())
        self.axes.set_ylabel(self.yLabelCtrl.GetValue())
        self.canvas.draw()

    def Animate(self, filename, directory):
        """
        Animate will create the sequence of images using self.CheckedKeys to 
        know which items to plot.
        """
        root, ext = os.path.splitext(filename)
        range = len(self.CheckedKeys)
        self.animateGauge.SetRange(range)
        for key, i in zip(self.CheckedKeys, xrange(range) ):
            self.axes.clear()
            self.Plot(key[1], key[1])
            fName = os.path.join(directory, "%s%03i%s" %(root, i, ext) ) 
            self.canvas.print_png( fName )
开发者ID:jlconlin,项目名称:PhDThesis,代码行数:104,代码来源:gnuFile.py


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