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


Python FigureCanvasWxAgg.draw_idle方法代码示例

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


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

示例1: Frame

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import draw_idle [as 别名]
    class Frame(wx.Frame):
        def __init__(self):
            wx.Frame.__init__(self, parent=None, title="Colourmap Selection")

            self.figure = Figure(dpi=80, figsize=(2,2))
            self.canvas = Canvas(self, -1, self.figure)
            self.axes = self.figure.gca()
            x = y = numpy.linspace(-3,3,80)
            X,Y = numpy.meshgrid(x,y)
            V = numpy.sin(Y**2+X**2)
            self.mapper = FigureImage(self.figure)
            im = self.axes.pcolor(x,y,V,shading='flat')
            try:
                cb = self.mapper.callbacksSM.connect('changed', ChangeCM(im))
            except AttributeError:   # Using 0.91 style
                self.mapper.add_observer(im)
            #self.figure.colorbar(self.mapper)

            sizer = wx.BoxSizer(wx.VERTICAL)
            sizer.Add(self.canvas,1,wx.EXPAND)
            self.SetSizer(sizer)

            self.canvas.Bind(wx.EVT_RIGHT_DOWN, self.OnContext)


        def OnContext(self, evt):
            popup = wx.Menu()
            item = popup.Append(wx.ID_ANY,'&Grid on/off', 'Toggle grid lines')
            wx.EVT_MENU(self, item.GetId(), self.OnGridToggle)
            cmapmenu = CMapMenu(self, callback = self.OnColormap,
                                mapper=self.mapper, canvas=self.canvas)
            item = popup.AppendMenu(wx.ID_ANY, "Colourmaps", cmapmenu)
            self.PopupMenu(popup, evt.GetPositionTuple())
        def OnColormap(self, name):
            print "Selected colormap",name
        def OnGridToggle(self, event):
            self.axes.grid()
            self.canvas.draw_idle()
开发者ID:reflectometry,项目名称:osrefl,代码行数:40,代码来源:cmapmenu.py

示例2: Plotter4

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import draw_idle [as 别名]
class Plotter4(wx.Panel):
    """
    The PlotPanel has a Figure and a Canvas. OnSize events simply set a
    flag, and the actually redrawing of the
    figure is triggered by an Idle event.
    """
    def __init__(self, parent, id = -1, dpi = None, color=None, **kwargs):
        # TODO: inherit directly from Canvas --- it is after all a panel.

        # Set up the panel parameters
        #style = wx.NO_FULL_REPAINT_ON_RESIZE
        wx.Panel.__init__(self, parent, id = id, **kwargs)
        self.Bind(wx.EVT_CONTEXT_MENU, self.onContextMenu)

        # Create the figure
        self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2,2))
        #self.canvas = NoRepaintCanvas(self, -1, self.figure)
        self.canvas = Canvas(self, -1, self.figure)
        self.canvas.mpl_connect('key_press_event',self.onKeyPress)
        self.canvas.mpl_connect('button_press_event',self.onButtonPress)
        self.canvas.mpl_connect('scroll_event',self.onWheel)
        # TODO use something for pan events
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas,1,wx.EXPAND)
        self.SetSizer(sizer)
        # Construct an idle timer.  This won't be needed when matplotlib
        # supports draw_idle for wx.
        #self.idle_timer = wx.CallLater(1,self.onDrawIdle)
        #self.Fit()

        # Create four subplots with no space between them.
        # Leave space for the colorbar.
        # Use a common set of axes.
        self.pp = self.figure.add_subplot(221)
        self.mm = self.figure.add_subplot(222,sharex=self.pp,sharey=self.pp)
        self.pm = self.figure.add_subplot(223,sharex=self.pp,sharey=self.pp)
        self.mp = self.figure.add_subplot(224,sharex=self.pp,sharey=self.pp)
        self.figure.subplots_adjust(left=.1, bottom=.1, top=.9, right=0.85,
                                    wspace=0.0, hspace=0.0)

        self.axes = [self.pp, self.mm, self.pm, self.mp]
        self.grid = True

        # Create the colorbar
        # Provide an empty handle to attach colormap properties
        self.coloraxes = self.figure.add_axes([0.88, 0.2, 0.04, 0.6])
        self.colormapper = mpl.image.FigureImage(self.figure)
        self.colormapper.set_array(numpy.ones(1))
        self.colorbar = self.figure.colorbar(self.colormapper,self.coloraxes)

        # Provide slots for the graph labels
        self.tbox = self.figure.text(0.5, 0.95, '',
                                     horizontalalignment='center',
                                     fontproperties=FontProperties(size=16))
        self.xbox = self.figure.text(0.5,0.01,'',
                                     verticalalignment='bottom',
                                     horizontalalignment='center',
                                     rotation='horizontal')
        self.ybox = self.figure.text(0.01,0.5,'',
                                     horizontalalignment='left',
                                     verticalalignment='center',
                                     rotation='vertical')
        self.zbox = self.figure.text(0.99,0.5,'',
                                     horizontalalignment='right',
                                     verticalalignment='center',
                                     rotation='vertical')

        self.xscale = 'linear'
        self.yscale = 'linear'
        self.zscale = 'linear'
        self.set_vscale('log')

        # Set up the default plot
        self.clear()

        self._sets = {} # Container for all plotted objects

    def autoaxes(self):
        return
        bbox = bbox_union([ax.dataLim for ax in self.axes])
        xlims = bbox.intervalx
        ylims = bbox.intervaly
        self.pp.axis(list(xlims)+list(ylims))

    def onKeyPress(self,event):
        #if not event.inaxes: return
        # Let me zoom and unzoom even without the scroll wheel
        if event.key == 'a':
            setattr(event,'step',5.)
            self.onWheel(event)
        elif event.key == 'z':
            setattr(event,'step',-5.)
            self.onWheel(event)

    def onButtonPress(self,event):
        # TODO: finish binder so that it allows tagging of fully qualified
        # events on an artist by artist basis.
        if event.inaxes == self.coloraxes:
            self.colormapper.set_clim(vmin=self.vmin,vmax=self.vmax)
            self.canvas.draw_idle()
#.........这里部分代码省略.........
开发者ID:reflectometry,项目名称:osrefl,代码行数:103,代码来源:polplot.py

示例3: ImagePanel

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

#.........这里部分代码省略.........
    def rotate90(self, event=None):
        "rotate 90 degrees, CW"
        self.conf.rot = True
        self.unzoom_all()

    def toggle_curmode(self, event=None):
        "toggle cursor mode"
        if self.conf.cursor_mode == 'zoom':
            self.conf.cursor_mode = 'lasso'
        else:
            self.conf.cursor_mode = 'zoom'

    ####
    ## GUI events, overriding BasePanel components
    ####
    def calc_indices(self):
        if self.conf.data is not None:
            ny, nx = self.conf.data.shape
            inds = []
            for iy in range(ny):
                inds.extend([(iy, ix) for ix in range(nx)])
            self.conf.indices = np.array(inds)


    def lassoHandler(self, vertices):
        conf = self.conf
        if conf.indices is None:
            self.calc_indices()

        ind = conf.indices
        mask = points_inside_poly(ind, vertices)
        sel = [(ind[i][0], ind[i][1]) for i in np.nonzero(mask)[0]]
        self.lasso = None
        self.canvas.draw_idle()
        if hasattr(self.lasso_callback , '__call__'):
            self.lasso_callback(data=conf.data, selected=sel,
                                mask=mask)

    def reportMotion(self,event=None):
        pass

    def unzoom(self, event=None, set_bounds=True):
        """ zoom out 1 level, or to full data range """
        lims = None
        if len(self.zoom_lims) > 1:
            lims = self.zoom_lims.pop()
        ax = self.axes
        if lims is None: # auto scale
            self.zoom_lims = [None]
            xmin, xmax, ymin, ymax = self.data_range
            lims = {self.axes: [xmin, xmax, ymin, ymax]}
        self.set_viewlimits() #   xylims(lims=lims[self.axes], axes=self.axes, autoscale=False)
        self.canvas.draw()

    def unzoom_all(self, event=None):
        """ zoom out full data range """
        self.zoom_lims = [None]
        self.unzoom(event)

    def redraw(self):
        """redraw image, applying the following:
        rotation, flips, log scale
        max/min values from sliders or explicit intensity ranges
        color map
        interpolation
        """
开发者ID:lx-88,项目名称:wxmplot,代码行数:70,代码来源:imagepanel.py

示例4: MyPlotPanel

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import draw_idle [as 别名]
class MyPlotPanel(wx.Panel):
    def __init__(self, parent, figsize=None, dpi=None, 
                 bgcolor=None, type=None, toolbar=None, aspect=1,
                 **kwargs):
        """ construction method of MyPlotPanel class
        :param parent: parent object
        :param figsize: plot figure size, (w, h)
        :param dpi: figure dpi,
        :parma bgcolor: background color of figure and canvas
        :param type: type of initial figure, 'image' or 'line'
        :param toolbar: show toolbar if not set None
        """
        wx.Panel.__init__(self, parent, **kwargs)
        self.parent = parent
        self.figsize = figsize
        self.dpi = dpi
        self.bgcolor = bgcolor
        self.type = type
        self.toolbar = toolbar
        self.aspect = aspect
        self.figure = Figure(self.figsize, self.dpi)
        self.canvas = FigureCanvas(self, -1, self.figure)

        # figure background color
        self.set_color(self.bgcolor)

        # initialize plot
        self._init_plot()

        # set layout
        self.set_layout()

        # binding events
        self.canvas.mpl_connect('button_press_event', self.on_press)
        self.canvas.mpl_connect('button_release_event', self.on_release)
        self.canvas.mpl_connect('motion_notify_event', self.on_motion)
        self.Bind(wx.EVT_SIZE, self.on_size)

    def set_layout(self):
        """ set panel layout
        """
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas, 1, wx.EXPAND)
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        if self.toolbar is not None:
            self.toobar = MyToolbar(self.canvas)
            self.toobar.Realize()
            hbox.Add(self.toobar, 0, wx.EXPAND | wx.RIGHT, 10)
        self.pos_st = wx.StaticText(self, label='')
        hbox.Add(self.pos_st, 0, wx.ALIGN_CENTER_VERTICAL)
        sizer.Add(hbox, 0, wx.EXPAND | wx.BOTTOM, 0)
        self.SetSizerAndFit(sizer)

    def _init_plot(self):
        if not hasattr(self, 'axes'):
            self.axes = self.figure.add_subplot(111, aspect=self.aspect)
        if self.type == 'image':  # draw image
            x = y = np.linspace(-np.pi, np.pi, 100)
            self.x, self.y = np.meshgrid(x, y)
            self.z = self._func_peaks(self.x, self.y)
            self.image = self.axes.imshow(self.z)
        else: # draw line
            self.x = np.linspace(-10, 10, 200)
            self.y = np.sin(self.x)
            self.line, = self.axes.plot(self.x, self.y)

    def set_color(self, rgb_tuple):
        """ set figure and canvas with the same color.
        :param rgb_tuple: rgb color tuple, 
                          e.g. (255, 255, 255) for white color
        """
        if rgb_tuple is None:
            rgb_tuple = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE).Get()
        clr = [c/255.0 for c in rgb_tuple]
        self.figure.set_facecolor(clr)
        self.figure.set_edgecolor(clr)
        self.canvas.SetBackgroundColour(wx.Colour(*rgb_tuple))
        
    def on_size(self, event):
        self.fit_canvas()
        self.canvas.draw_idle()
        event.Skip()

    def on_press(self, event):
        pass

    def on_release(self, event):
        pass

    def on_motion(self, event):
        if event.inaxes is not None:
            self.pos_st.SetLabel("({x:<.4f}, {y:<.4f})".format(x=event.xdata, y=event.ydata))

    def fit_canvas(self):
        """ tight fit canvas layout
        """
        #self.canvas.SetSize(self.GetSize())
        self.figure.set_tight_layout(True)
        
    def _func_peaks(self, x, y):
#.........这里部分代码省略.........
开发者ID:guduan,项目名称:beamline,代码行数:103,代码来源:pltutils.py

示例5: plotTimeSeries

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import draw_idle [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

示例6: MainPanel

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import draw_idle [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

示例7: MyFrame

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

#.........这里部分代码省略.........
    def OnPlot(self,evt):
        #print (self._get_conf())
        #print("plot")
        sig_file,samps_per_ui,data_rate,sinc_interp_n,\
        clock_times_file,ignor_cycles,colorbar_en,\
        mask_en,mask_path = self._get_conf()
        sig = np.loadtxt(sig_file)
        if clock_times_file is not None:
            clock_times = np.loadtxt(clock_times_file)[ignor_cycles:]
        else:
            clock_times = None
        #print(len(sig))
        if sinc_interp_n>0: 
            sig = resample(sig,len(sig)*sinc_interp_n)
            samps_per_ui *= sinc_interp_n

        ui = 1e-9/data_rate
        if mask_en:
            if mask_path:
                norm_mask1 = np.loadtxt(mask_path,delimiter=",")
                eye_mask = self.get_mask(norm_mask1,ui*1e12)
            else:
                eye_mask = None # should print some errors
        else:
            eye_mask = None

        self.plot_eye(sig,samps_per_ui,ui,clock_times,
                colorbar_en,eye_mask)

    def OnAdjustMask(self,evt):
        val = evt.EventObject.GetValue()
        mask_temp = self.mask_array.copy()
        mask_temp[:,0] = self.mask_array[:,0]+val
        self.mask_poly.set_xy(mask_temp)
        self.canvas.draw_idle()
        
    def OnEnableEyeMask(self,evt):
        mask_en = evt.EventObject.GetValue()
        self.fbb_mask_path.Enable(mask_en)
        self.sld_maskadj.Enable(mask_en)



    def get_mask(self,norm_mask,ui,vhigh=1,vlow=-1):
        mask = norm_mask.copy()
        mask[:,0]-=0.5
        mask[:,0] *= ui
        mask[:,1] -= 0.5
        mask[:,1] *= (vhigh-vlow)
        return mask



    def plot_eye(self,sig, samps_per_ui, ui, clock_times=None,
            colorbar_en=False,eye_mask=None,grid_size=(480,640)):
        
        #def update_mask(val):
            #print(val)
        #    mask_temp = mask_array.copy()
        #    mask_temp[:,0]=mask_array[:,0]+val
        #    mask_poly.set_xy(mask_temp)
        #    self.canvas.draw_idle()
        
        self.figure.clf()
        
        self.axes1 = self.figure.add_subplot(1,1,1)
        self.eye_mask_en = False if eye_mask == None else True
        xs,ys,eye_heat = calc_eye_heatmap(sig, samps_per_ui, ui, clock_times, grid_size) 
        im = self.axes1.pcolormesh(xs,ys,eye_heat,cmap=scope_cmap,
                shading="gouraud")

        self.axes1.set_xlabel("Time(ps)")
        self.axes1.set_ylabel("Voltage(v)")
        
        if colorbar_en:
            self.figure.colorbar(im, ax=self.axes1)
        self.axes1.set_xlim([xs.min(),xs.max()])
        self.axes1.set_ylim([ys.min(),ys.max()])
        self.axes1.grid(color="w")


        if self.eye_mask_en:
            #self.figure.subplots_adjust(bottom=0.25)        
            #self.axes2 = self.figure.add_axes([0.2, 0.1, 0.65, 0.03])
            #self.slide_mask = Slider(self.axes2, 'Mask Adjust', -ui*1e12,
            #        ui*1e12, valinit=0)
            #self.slide_mask.on_changed(update_mask)
        
            self.mask_array = eye_mask
            self.mask_poly = mpl.patches.Polygon(self.mask_array,color='#3F3F3F',
                    alpha=0.75)

            self.axes1.add_patch(self.mask_poly) 
            self.sld_maskadj.SetRange(xs.min(),xs.max())
        #else:
        #    self.figure.subplots_adjust(bottom=0.1)   

 

        self.canvas.draw()
开发者ID:leeooox,项目名称:eye_probe,代码行数:104,代码来源:eye_probe.py

示例8: MyPlotPanel

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

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

    def _init_plot(self):
        if not hasattr(self, 'axes'):
            self.axes = self.figure.add_subplot(111, aspect=self.aspect)
        if self.type == 'image':  # draw image
            x = y = np.linspace(-np.pi, np.pi, 100)
            self.x, self.y = np.meshgrid(x, y)
            self.z = self._func_peaks(self.x, self.y)
            self.image = self.axes.imshow(self.z)
        else:  # draw line
            self.x = np.linspace(-10, 10, 200)
            self.y = np.sin(self.x)
            self.line, = self.axes.plot(self.x, self.y)

    def _post_init(self):
        self._set_xylim_flag(self.xylim_choice.GetStringSelection())

    def set_color(self, rgb_tuple):
        """ set figure and canvas with the same color.
        :param rgb_tuple: rgb color tuple,
                          e.g. (255, 255, 255) for white color
        """
        if rgb_tuple is None:
            #rgb_tuple = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE).Get()
            rgb_tuple = wx.SystemSettings.GetColour(
                wx.SYS_COLOUR_DESKTOP).Get()
        clr = [c / 255.0 for c in rgb_tuple]
        self.figure.set_facecolor(clr)
        self.figure.set_edgecolor(clr)
        self.canvas.SetBackgroundColour(wx.Colour(*rgb_tuple))

    def on_size(self, event):
        self.fit_canvas()
        self.canvas.draw_idle()
        event.Skip()

    def on_press(self, event):
        pass

    def on_release(self, event):
        pass

    def on_pick(self, event):
        pass

    def on_motion(self, event):
        if event.inaxes is not None:
            self.pos_st.SetLabel(
                "({x:<.4f}, {y:<.4f})".format(x=event.xdata, y=event.ydata))

    def fit_canvas(self):
        """ tight fit canvas layout
        """
        #self.canvas.SetSize(self.GetSize())
        self.figure.set_tight_layout(True)

    def _func_peaks(self, x, y):
        return 3.0 * (1.0 - x)**2.0 * np.exp(-(x**2) - (y+1)**2) \
             - 10*(x/5 - x**3 - y**5) * np.exp(-x**2-y**2) \
             - 1.0/3.0*np.exp(-(x+1)**2 - y**2)

    def refresh(self):
        self.canvas.draw_idle()

    def xylim_choiceOnChoice(self, event):
        sel_str = self.xylim_choice.GetStringSelection()
开发者ID:archman,项目名称:felapps,代码行数:70,代码来源:uiutils.py


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