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


Python FigureCanvasWxAgg.widgetlock方法代码示例

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


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

示例1: plotTimeSeries

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

#.........这里部分代码省略.........
      if count >1:
        # self.timeSeries.set_title("Multiple Series plotted")
        self.timeSeries.set_title("")
        plt.subplots_adjust(bottom=.1+.1)
        # self.timeSeries.legend(loc='upper center', bbox_to_anchor=(0.5, -0.05),
        #      ncol=2, prop = self.fontP)
        self.timeSeries.legend(loc='upper center', bbox_to_anchor=(0.5, -0.15),
             ncol=2, prop = self.fontP)
      elif count == 0:
        self.timeSeries.set_title("")
        self.timeSeries.legend_=None
      else:
        self.timeSeries.set_title(oneSeries.plotTitle)
        plt.subplots_adjust(bottom=.1)
        self.timeSeries.legend_=None


      # self.timeSeries.set_xlim([0,1000])
      self.timeSeries.set_xlabel("Date Time")
      self.canvas.draw()



  def setEdit(self, id):
      self.editseriesID = id
      if self.seriesPlotInfo and self.seriesPlotInfo.IsPlotted(self.editseriesID):
        self.editCurve = self.seriesPlotInfo.GetSeries(self.editseriesID)
        self.updatePlot()
        # print self.editCurve



  def setUpYAxis(self):
    self.axislist={}
    left = 0
    right = 0
    adj = .05
    #loop through the list of curves and add an axis for each
    for oneSeries in self.seriesPlotInfo.GetSeriesInfo():
      #test to see if the axis already exists
      if not oneSeries.axisTitle in self.axislist:
        self.axislist[oneSeries.axisTitle]=None


    for i, axis in zip(range(len(self.axislist)), self.axislist):
      if i %2==0:
        left = left+1
        #add to the left(yaxis)
        if i==0:
          #if first plot use the orig axis
          newAxis =self.timeSeries
        else:
          newAxis= self.timeSeries.twinx()
          new_fixed_axis = newAxis.get_grid_helper().new_fixed_axis
          newAxis.axis['left']= new_fixed_axis(loc = 'left', axes= newAxis, offset= (-30*left ,0))
          newAxis.axis["left"].toggle(all = True)
          newAxis.axis["right"].toggle(all = False)
          plt.subplots_adjust(left=.10+(adj*(left-1)))

      else:
        right= right+1
        #add to the right(y2axis)
        newAxis= self.timeSeries.twinx()
        new_fixed_axis = newAxis.get_grid_helper().new_fixed_axis
        newAxis.axis['right']= new_fixed_axis(loc = 'right', axes= newAxis, offset= (60*(right-1) ,0))
        newAxis.axis['right'].toggle(all=True)
        plt.subplots_adjust(right=.9-(adj*right))

      newAxis.set_ylabel(axis)
      self.axislist[axis]=newAxis




  def callback(self, verts):
      seldatetimes= [matplotlib.dates.num2date(x[0]) for x in verts]
      #print seldatetimes

      # self.parent.record_service.select_points(datetime_list=seldatetimes)

      p = path.Path(verts)
      ind = p.contains_points(self.xys)
      self.changeSelection(ind)

      self.canvas.draw_idle()
      self.canvas.widgetlock.release(self.lasso)
      del self.lasso



  def onpress(self, event):
      if self.canvas.widgetlock.locked(): return
      if event.inaxes is None: return
      self.lasso = Lasso(event.inaxes, (event.xdata, event.ydata), self.callback)
      # acquire a lock on the widget drawing
      self.canvas.widgetlock(self.lasso)


  def __init__(self, parent, id, pos, size, style, name):
      self._init_ctrls(parent)
开发者ID:RussNelson,项目名称:ODMToolsPython,代码行数:104,代码来源:plotTimeSeries.py

示例2: MainPanel

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

#.........这里部分代码省略.........
        
        #self.axes.set_xlabel(r'$\Delta_i$', fontsize=20)
        #self.axes.set_ylabel(r'$\Delta_{i+1}$', fontsize=20)
        #self.axes.set_title('Volume and percent change')
        #self.axes.grid(True)
        ### use zoom instead
        #self.xmin = self.data1.min()# - (self.data1.max() * 0.1)
        #self.xmax = self.data1.max()# * 1.1
        #self.ymin = self.data2.min()# - (self.data2.max() * 0.1)
        #self.ymax = self.data2.max()# * 1.1

        
    def build_graph(self):

        self.axes = self.figure.add_subplot(111, axisbg=(1,1,1))
        self.figure.subplots_adjust(left=0, right=1, top=1, bottom=0)
        #self.axes.frame_on(False)
        #subplot(111, axisbg='darkslategray')
        #ax = fig.add_subplot(111)
        #self.axes.scatter(self.data2, self.data1, c=[0.5,0.5,1.0], s=200, alpha=0.5)
        
    def build_collection(self):
        self.point_size = self.sl_x2_pointsize.GetValue() + 50 # range 50 to 300
        self.collection = RegularPolyCollection(
            #self.axes.figure.dpi,
            numsides = 80, 
            sizes=(self.point_size,),
            facecolors=self.color_array,
            offsets = self.data_array,            
            transOffset = self.axes.transData)
        self.collection.set_alpha(0.7)
        self.axes.add_collection(self.collection)        
        
        #self.axes.axis([self.xmin, self.xmax, self.ymin, self.ymax])
        self.axes.autoscale_view()
        x = self.axes.get_xaxis()
        y = self.axes.get_yaxis()
        x.zoom(-1)
        y.zoom(-1)
        #self.axes.axis('tight')
        ##self.axes.axis('off')        
        
    def callback(self, verts):
        facecolors = self.collection.get_facecolors()
        ind = nonzero(points_inside_poly(self.data_array, verts))[0]
        for i in range(len(self.data_array)):
            if i in ind:
                facecolors[i] = (1,1,0,.5)
                #print facecolors[i]
                #pass
            else:
                facecolors[i] = self.color_array[i]
                #pass

        #print facecolors[i]
        self.canvas.draw_idle()
        self.canvas.widgetlock.release(self.lasso)
        del self.lasso
        #self.ind = ind
        self.pass_data(ind)
        
    def onpress(self, event):
        #print event.button
        if self.canvas.widgetlock.locked(): 
            #print 'foo'
            self.canvas.widgetlock.release(self.lasso)
            #return
        if event.inaxes is None: 
            return
        self.lasso = Lasso(event.inaxes, (event.xdata, event.ydata), self.callback)
        # acquire a lock on the widget drawing
        self.canvas.widgetlock(self.lasso)
        
    def pass_data(self, ind):
        #populate parents list control
        self.lc_x2_plist.DeleteAllItems()
        for x in ind:
            self.lc_x2_plist.InsertStringItem(0, self.song_array[x][0])
            self.lc_x2_plist.SetStringItem(0, 1, self.song_array[x][1])
        #pass
            
    def update_data(self):
        pass
        #self.figure.clf()
        #build_graph(self)
        #self.MakeScatt()
        #self.build_collection()
        
    def OnAutoGenerateX2Playist(self, event):
        # copy the sifted list to the playlist
        self.parent.CheckClear()
        insert_at = self.parent.lc_playlist.GetItemCount()
        for x in range(self.lc_x2_plist.GetItemCount(), 0, -1):
            artist = self.lc_x2_plist.GetItem(x-1, 0).GetText()
            song = self.lc_x2_plist.GetItem(x-1, 1).GetText()
            self.parent.SetPlaylistItem(insert_at, artist, song, '', '')
        #save the playlist
        self.parent.SavePlaylist()
        # switch tabs
        self.parent.nb_main.SetSelection(self.nb_playlist)
开发者ID:Alwnikrotikz,项目名称:turnip-town,代码行数:104,代码来源:x2.py


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