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


Python FigureCanvasWxAgg.print_bmp方法代码示例

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


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

示例1: FigurePanel

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import print_bmp [as 别名]
class FigurePanel(wx.Panel):
    def __init__(self, parent, data):
        wx.Panel.__init__(self, parent)

        # make sizers of panel
        self.sizerMainFrame = wx.BoxSizer(wx.VERTICAL)

        # make figure
        self.figure = Figure()

        self.canvas = FigureCanvas(self, -1, self.figure)
        self.toolbar = NavigationToolbar(self.canvas)
        self.toolbar.Hide()

        # self.UpdateFigurePanel(data)

        # make save button on the top of the panel
        self.sizerBtn = wx.BoxSizer(wx.HORIZONTAL)
        self.sizerMainFrame.Add(self.sizerBtn)

        btn1 = wx.Button(self, wx.ID_ANY, label="&Save")

        self.sizerBtn.Add(btn1, proportion=0, flag=wx.ALL | wx.ALIGN_LEFT, border=5)

        self.Bind(wx.EVT_BUTTON, self.OnSave, btn1)

        # make panel with btn and figure
        self.sizerMainFrame.Add(self.canvas, 1, wx.EXPAND)

        # update sizers
        self.SetSizer(self.sizerMainFrame)
        self.Layout()

    def Hist(self, data, pars):

        if data != []:
            self.data = numpy.array(data)  # Define the data in the class, can use in the future. 

            ax = self.figure.add_subplot(111)
            ax.hold(False)
            # ax.plot(self.data[1:, 0], self.data[1:, 1], '*-')
            ax.hist(self.data[pars[1]:, pars[0]:].astype(float).reshape(-1), color = 'green', normed=1, histtype="bar",  alpha=0.8)
            self.canvas.draw()
    
    def Scatplot(self, data, pair):
        if data != []:
            self.data = numpy.array(data)

            ax = self.figure.add_subplot(111)
            ax.clear()
            # ax.plot(self.data[1:, 0], self.data[1:, 1], '*-')
            if (pair[0] == "col"):
                ax.scatter(self.data[pair[3]:, pair[1]].astype(float),self.data[pair[3]:, pair[2]].astype(float) )
            else:
                ax.scatter(self.data[pair[1], pair[3]:].astype(float),self.data[pair[2],pair[3]: ].astype(float) )
            self.canvas.draw()        

    def SaveFigure(self, name):
        self.canvas.print_bmp(filename=name+'.bmp')

    def OnSave(self, event):
        outputDlg = OutputDialog()
        outPath, fileName = outputDlg.GetPath()
        print outPath 
        fileName = outPath + "/" + fileName + ".bmp"       
        self.canvas.print_bmp(fileName)
开发者ID:laobaixing,项目名称:iBAS,代码行数:68,代码来源:iBASfigure.py


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