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


Python NavigationToolbar2WxAgg.save方法代码示例

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


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

示例1: initialFrame

# 需要导入模块: from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.NavigationToolbar2WxAgg import save [as 别名]
class initialFrame(wx.Frame):
    """ The main frame of the application
    """
    title = "Bangsimon Stocks"
    def __init__(self):
        #Create everything
        super(initialFrame,self).__init__( None, -1, self.title,)
        self.Bind(wx.EVT_CLOSE, self.on_exit)
        self.create_menu()
        self.create_status_bar()
        print "Fetching initial data"
        self.create_main_panel()
        
        print "Plotting initial data"
        self.draw_figure()

        
    def create_menu(self):
        """Creates the menubar"""
        self.menubar = wx.MenuBar()
        
        menu_file = wx.Menu()
        m_new = menu_file.Append(-1, "&New ticker\tCtrl-N", "Choose new ticker to track")
        self.Bind(wx.EVT_MENU, self.on_new, m_new)
        
        m_expt = menu_file.Append(-1, "&Save plot\tCtrl-S", "Save plot to file")
        self.Bind(wx.EVT_MENU, self.on_save_plot, m_expt)
        
        menu_file.AppendSeparator()
        m_exit = menu_file.Append(-1, "E&xit\tCtrl-X", "Exit")
        self.Bind(wx.EVT_MENU, self.on_exit, m_exit)
        
        plot = wx.Menu()
        options = ['Adj Close','Open' ,'High', 'Low', 'Close', 'Avg. Price']
        #Use map instead of multible copy paste
        M = map( (lambda x: self.Bind(wx.EVT_MENU,self.plot_handler,
                                      plot.AppendRadioItem(-1,x))),options)
        plot.AppendSeparator()

        #We want these to be on the same graph, option to turn on or off
        self.Bind(wx.EVT_MENU,self.plot_handler,plot.AppendCheckItem(-1, "Simple Moving Average"))
        self.Bind(wx.EVT_MENU,self.plot_handler,plot.AppendCheckItem(-1, "Volume"))


        dates = wx.Menu()
        self.Bind(wx.EVT_MENU,self.changeFromDate,dates.Append(-1, "Change From Date"))
        self.Bind(wx.EVT_MENU,self.changeToDate,dates.Append(-1, "Change To Date"))

        comp = wx.Menu()
        
        self.Bind(wx.EVT_MENU,self.tiProfile,comp.Append(-1, "Profile"))
        self.Bind(wx.EVT_MENU,self.tiKeys,comp.Append(-1, "Key Statistics"))
        
        self.menubar.SetMenus([(menu_file,"&File"),(plot, "&Plot"),(dates,"&Dates"),(comp, "&Company")])
        
        self.SetMenuBar(self.menubar)

            

    def create_main_panel(self):
        """ Creates the main panel and everything"""

        self.panel = wx.Panel(self)
        self.panel.stockObj = stockInfo(DEFAULT_TICKER)
        
        #Put up some default values that are used in plot
        self.panel.currentAttr = "Adj Close"
        td = self.panel.stockObj.toDate - timedelta(weeks=DEFAULT_PERIOD)
        if self.panel.stockObj.validDate(td):
            self.panel.fromDate = td
        else:
            self.panel.fromDate = self.panel.stockObj.fromDate
            
        self.panel.toDate = self.panel.stockObj.toDate
        self.panel.MovingAvg = False
        self.panel.Volume = False
        self.panel.MovingAvgN = 20
        self.panel.Beta = Beta(self.panel.stockObj,self.panel.fromDate, self.panel.toDate)
       
        #adding the pllot
        self.fig = matplotlib.pyplot.gcf()
        self.canvas = FigCanvas(self.panel, -1, self.fig)
        
        #Add slider to change n of moving average
        self.slider_label = wx.StaticText(self.panel, -1, 
            "Moving Average N: ")
        self.slider_width = wx.Slider(self.panel, -1, 
            value=20, 
            minValue=20,
            maxValue=200,
            style=wx.SL_AUTOTICKS | wx.SL_LABELS)
        self.slider_width.SetTickFreq(10, 1)
        self.Bind(wx.EVT_COMMAND_SCROLL_THUMBTRACK, self.on_slider_width, self.slider_width)
        self.Bind(wx.EVT_COMMAND_SCROLL_CHANGED, self.on_slider_width, self.slider_width)

        #Toolbar of chart
        self.toolbar = NavigationToolbar(self.canvas)
        self.SetToolBar(self.toolbar)
        self.toolbar.Realize()#: Windows fix, does not work
       
#.........这里部分代码省略.........
开发者ID:Tritlo,项目名称:BangsimonStocks,代码行数:103,代码来源:stockGUI.py


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