Python matplotlib 模块,figure() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用matplotlib.figure()

项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def redraw_overplot_on_image(self, *args):
        if self.star_center_patch is not None:
            self.ztv_frame.primary_image_panel.axes.patches.remove(self.star_center_patch)
        if self.star_aperture_patch is not None:
            self.ztv_frame.primary_image_panel.axes.patches.remove(self.star_aperture_patch)
        if self.sky_aperture_patch is not None:
            self.ztv_frame.primary_image_panel.axes.patches.remove(self.sky_aperture_patch)
        self.star_center_patch = Circle([self.xcentroid, self.ycentroid], 0.125, color=self.aprad_color)
        self.ztv_frame.primary_image_panel.axes.add_patch(self.star_center_patch)
        self.star_aperture_patch = Circle([self.xcentroid, self.ycentroid], self.aprad, color=self.aprad_color, alpha=self.alpha)
        self.ztv_frame.primary_image_panel.axes.add_patch(self.star_aperture_patch)
        self.sky_aperture_patch = Wedge([self.xcentroid, self.ycentroid], self.skyradout, 0., 360., 
                                        width=self.skyradout - self.skyradin, color=self.skyrad_color, alpha=self.alpha)
        self.ztv_frame.primary_image_panel.axes.add_patch(self.sky_aperture_patch)
        self.ztv_frame.primary_image_panel.figure.canvas.draw()
        self.hideshow_button.SetLabel(u"Hide")
项目:leetcode    作者:thomasyimgit    | 项目源码 | 文件源码
def test_select_figure_formats_kwargs():
    ip = get_ipython()
    kwargs = dict(quality=10, bbox_inches='tight')
    pt.select_figure_formats(ip, 'png', **kwargs)
    formatter = ip.display_formatter.formatters['image/png']
    f = formatter.lookup_by_type(Figure)
    cell = f.__closure__[0].cell_contents
    nt.assert_equal(cell, kwargs)

    # check that the formatter doesn't raise
    fig = plt.figure()
    ax = fig.add_subplot(1,1,1)
    ax.plot([1,2,3])
    plt.draw()
    formatter.enabled = True
    png = formatter(fig)
    assert png.startswith(_PNG)
项目:leetcode    作者:thomasyimgit    | 项目源码 | 文件源码
def getfigs(*fig_nums):
    """Get a list of matplotlib figures by figure numbers.

    If no arguments are given, all available figures are returned.  If the
    argument list contains references to invalid figures, a warning is printed
    but the function continues pasting further figures.

    Parameters
    ----------
    figs : tuple
        A tuple of ints giving the figure numbers of the figures to return.
    """
    from matplotlib._pylab_helpers import Gcf
    if not fig_nums:
        fig_managers = Gcf.get_all_fig_managers()
        return [fm.canvas.figure for fm in fig_managers]
    else:
        figs = []
        for num in fig_nums:
            f = Gcf.figs.get(num)
            if f is None:
                print('Warning: figure %s not available.' % num)
            else:
                figs.append(f.canvas.figure)
        return figs
项目:MDT    作者:cbclab    | 项目源码 | 文件源码
def __init__(self, figure, plotting_info_viewer, controller):
        self.figure = figure
        self.plotting_info_viewer = plotting_info_viewer
        self.controller = controller

        self._axes_data = []
        self.figure.canvas.mpl_connect('button_press_event', self._button_pressed)
        self.figure.canvas.mpl_connect('button_release_event', self._button_released)
        self.figure.canvas.mpl_connect('motion_notify_event', self._mouse_motion)
        self.figure.canvas.mpl_connect('scroll_event', self._scroll_event)
        self.figure.canvas.mpl_connect('key_press_event', self._on_key_press)
        self.figure.canvas.mpl_connect('key_release_event', self._on_key_release)

        self._in_drag = False
        self._control_is_held = False

        self._scrolling_manager = _ScrollingManager(controller)
        self._dragging_manager = _DraggingManager(controller)
项目:skan    作者:jni    | 项目源码 | 文件源码
def make_figure_window(self):
        self.figure_window = tk.Toplevel(self)
        self.figure_window.wm_title('Preview')
        screen_dpi = self.figure_window.winfo_fpixels('1i')
        screen_width = self.figure_window.winfo_screenwidth()  # in pixels
        figure_width = screen_width / 2 / screen_dpi
        figure_height = 0.75 * figure_width
        self.figure = Figure(figsize=(figure_width, figure_height),
                             dpi=screen_dpi)
        ax0 = self.figure.add_subplot(221)
        axes = [self.figure.add_subplot(220 + i, sharex=ax0, sharey=ax0)
                for i in range(2, 5)]
        self.axes = np.array([ax0] + axes)
        canvas = FigureCanvasTkAgg(self.figure, master=self.figure_window)
        canvas.show()
        canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
        toolbar = NavigationToolbar2TkAgg(canvas, self.figure_window)
        toolbar.update()
        canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
项目:yt    作者:yt-project    | 项目源码 | 文件源码
def __init__(self, viewer, window_plot, frb, field, font_properties,
                 font_color):
        self.frb = frb
        self.data = frb.data_source
        self._axes = window_plot.axes
        self._figure = window_plot.figure
        if len(self._axes.images) > 0:
            self.image = self._axes.images[0]
        if frb.axis < 3:
            DD = frb.ds.domain_width
            xax = frb.ds.coordinates.x_axis[frb.axis]
            yax = frb.ds.coordinates.y_axis[frb.axis]
            self._period = (DD[xax], DD[yax])
        self.ds = frb.ds
        self.xlim = viewer.xlim
        self.ylim = viewer.ylim
        if 'OffAxisSlice' in viewer._plot_type:
            self._type_name = "CuttingPlane"
        else:
            self._type_name = viewer._plot_type
        self.aspect = window_plot._aspect
        self.font_properties = font_properties
        self.font_color = font_color
        self.field = field
项目:yt    作者:yt-project    | 项目源码 | 文件源码
def show_mpl(self, im, enhance=True, clear_fig=True):
        if self._pylab is None:
            import pylab
            self._pylab = pylab
        if self._render_figure is None:
            self._render_figure = self._pylab.figure(1)
        if clear_fig: self._render_figure.clf()

        if enhance:
            nz = im[im > 0.0]
            nim = im / (nz.mean() + 6.0 * np.std(nz))
            nim[nim > 1.0] = 1.0
            nim[nim < 0.0] = 0.0
            del nz
        else:
            nim = im
        ax = self._pylab.imshow(nim[:,:,:3]/nim[:,:,:3].max(), origin='upper')
        return ax
项目:yt    作者:yt-project    | 项目源码 | 文件源码
def plot_allsky_healpix(image, nside, fn, label = "", rotation = None,
                        take_log = True, resolution=512, cmin=None, cmax=None):
    import matplotlib.figure
    import matplotlib.backends.backend_agg
    if rotation is None: rotation = np.eye(3).astype("float64")

    img, count = pixelize_healpix(nside, image, resolution, resolution, rotation)

    fig = matplotlib.figure.Figure((10, 5))
    ax = fig.add_subplot(1,1,1,projection='aitoff')
    if take_log: func = np.log10
    else: func = lambda a: a
    implot = ax.imshow(func(img), extent=(-np.pi,np.pi,-np.pi/2,np.pi/2),
                       clip_on=False, aspect=0.5, vmin=cmin, vmax=cmax)
    cb = fig.colorbar(implot, orientation='horizontal')
    cb.set_label(label)
    ax.xaxis.set_ticks(())
    ax.yaxis.set_ticks(())
    canvas = matplotlib.backends.backend_agg.FigureCanvasAgg(fig)
    canvas.print_figure(fn)
    return img, count
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def __init__(self, master = []):

        self.master = master

        # Erstellen des Fensters mit Rahmen und Canvas
        self.figure = Figure(figsize = (7, 7), dpi = 100)
        self.frame_c = Frame(relief = GROOVE, bd = 2)
        self.frame_c.pack(fill = BOTH, expand = 1,)
        self.canvas = FigureCanvasTkAgg(self.figure, master = self.frame_c)
        self.canvas.show()
        self.canvas.get_tk_widget().pack(fill = BOTH, expand = 1)

        # Erstellen der Toolbar unten
        self.toolbar = NavigationToolbar2TkAgg(self.canvas, self.frame_c)
        self.toolbar.update()
        self.canvas._tkcanvas.pack(fill = BOTH, expand = 1)
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def plot_lines_plot(self, lines, sb_nr = 111, text = "", wtp = [True, True, True]):
        self.plot1 = self.figure.add_subplot(sb_nr)
        self.plot1.set_title("Lines Plot %s" % sb_nr)
        self.plot1.grid(b = True, which = 'both', color = '0.65', linestyle = '-')
        self.plot1.hold(True)
        self.plot1.text(0.5, 0, text, ha = 'left', fontsize = 8)

        for line_nr in range(len(lines)):

            line = lines[line_nr]
            if wtp[0]:
                line.plot2plot(self.plot1)
            if wtp[1]:
                line.Ps.plot2plot(self.plot1, format = 'xr')
                line.Pe.plot2plot(self.plot1, format = 'og')
            Ps = (line.Ps + line.Pe) * 0.5
            if wtp[2]:
                self.plot1.text(Ps.x, Ps.y, line_nr, ha = 'left', fontsize = 10, color = 'red')

        self.plot1.axis('scaled')
        self.plot1.margins(y = .1, x = .1)
        self.plot1.autoscale(True, 'both', False)
        self.canvas.show()
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def ini_plot(self):
        self.plot1 = self.figure.add_subplot(211)
        self.plot1.set_title("Number of Lines: " +str(self.iter.Lines.num))

        self.plot2 = self.figure.add_subplot(212)
        self.plot2.set_title(('Best Tour length: %0.1f ' % (self.iter.Fittness.best_fittness[-1])))
        self.plot2.set_xlabel('Iteration')
        self.plot2.set_ylabel('Tour Length')        

        nr = 0
        self.plot1.hold(True)
        for line in self.iter.Lines.lines:
            line.plot_line(self.plot1,'-ro')
            line.add_text(self.plot1, str(nr))
            nr += 1

        self.lines1 = []
        con_lines = self.gen_plot_route()
        for line in con_lines:
            line.plot_line(self.plot1,'-b')

        best_fittness = self.iter.Fittness.best_fittness
        self.line2 = self.plot2.plot(range(len(best_fittness)), best_fittness, 'r-')
        self.plot2.set_ylim(0, best_fittness[0]+5)
        self.canvas.show()
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def __init__(self,master=[]):

        self.master=master

        #Erstellen des Fensters mit Rahmen und Canvas
        self.figure = Figure(figsize=(7,7), dpi=100)
        self.frame_c=Frame(relief = GROOVE,bd = 2)
        self.frame_c.pack(fill=BOTH, expand=1,)
        self.canvas = FigureCanvasTkAgg(self.figure, master=self.frame_c)
        self.canvas.show()
        self.canvas.get_tk_widget().pack(fill=BOTH, expand=1)

        #Erstellen der Toolbar unten
        self.toolbar = NavigationToolbar2TkAgg(self.canvas, self.frame_c)
        self.toolbar.update()
        self.canvas._tkcanvas.pack( fill=BOTH, expand=1)
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def make_ellipse_biarc_plot(self,ellipse):
        self.plot1 = self.figure.add_subplot(111)
        self.plot1.set_title("Ellipse, BIARC Fitting Algorithms: ")

        arrow_len=4
        arrow_width=arrow_len*0.05


        self.plot1.hold(True)
        for PtsVec in ellipse.PtsVec:
            (PtsVec[0].x)
            (PtsVec[0].y)
            self.plot1.plot([PtsVec[0].x],[PtsVec[0].y],'xr')

            self.plot1.arrow(PtsVec[0].x,PtsVec[0].y,\
                             cos(PtsVec[1])*arrow_len,\
                             sin(PtsVec[1])*arrow_len,\
                             width=arrow_width)        

        for geo in ellipse.geo:
            geo.plot2plot(self.plot1)
        self.plot1.axis('scaled')     
        self.canvas.show()
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def __init__(self):
        wx.Frame.__init__(self,None,-1,
                         'CanvasFrame',size=(550,350))



        self.SetBackgroundColour(wx.NamedColor("WHITE"))

        self.figure = Figure()
        self.axes = self.figure.add_subplot(111)

        self.canvas = FigureCanvas(self, -1, self.figure)

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
        self.SetSizer(self.sizer)
        self.Fit()

        self.add_toolbar()  # comment this out for no toolbar

        self.axes.set_title("NURBS and B-Spline Algorithms: ")
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def add_toolbar(self):
        self.toolbar = NavigationToolbar2Wx(self.canvas)
        self.toolbar.Realize()
        if wx.Platform == '__WXMAC__':
            # Mac platform (OSX 10.3, MacPython) does not seem to cope with
            # having a toolbar in a sizer. This work-around gets the buttons
            # back, but at the expense of having the toolbar at the top
            self.SetToolBar(self.toolbar)
        else:
            # On Windows platform, default window size is incorrect, so set
            # toolbar width to figure width.
            tw, th = self.toolbar.GetSizeTuple()
            fw, fh = self.canvas.GetSizeTuple()
            # By adding toolbar in sizer, we are able to put it at the bottom
            # of the frame - so appearance is closer to GTK version.
            # As noted above, doesn't work for Mac.
            self.toolbar.SetSize(wx.Size(fw, th))
            self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        # update the axes menu on the toolbar
        self.toolbar.update()
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def redraw_overplot_on_image(self, msg=None):
        if self.primary_image_patch is not None:
            self.ztv_frame.primary_image_panel.axes.patches.remove(self.primary_image_patch)
        if self.start_pt == self.end_pt:
            path = Path([self.start_pt, self.start_pt + (0.5, 0.),
                         self.start_pt, self.start_pt + (-0.5, 0.), 
                         self.start_pt, self.start_pt + (0., 0.5), 
                         self.start_pt, self.start_pt + (0., -0.5), self.start_pt], 
                        [Path.MOVETO, Path.LINETO, Path.LINETO, Path.LINETO, Path.LINETO, 
                         Path.LINETO, Path.LINETO, Path.LINETO, Path.LINETO])
        else:
            path = Path([self.start_pt, self.end_pt], [Path.MOVETO, Path.LINETO])
        self.primary_image_patch = PathPatch(path, color='magenta', lw=1)
        self.ztv_frame.primary_image_panel.axes.add_patch(self.primary_image_patch)
        self.ztv_frame.primary_image_panel.figure.canvas.draw()
        self.hideshow_button.SetLabel(u"Hide")
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def set_and_get_xy_limits(self):
        canvas_size = self.canvas.GetSize()
        num_x_pixels = canvas_size.x
        halfsize = (num_x_pixels / 2.0) / self.ztv_frame.zoom_factor
        xlim = (self.center.x - halfsize, self.center.x + halfsize)
        self.axes.set_xlim(xlim)
        num_y_pixels = canvas_size.y
        halfsize = (num_y_pixels / 2.0) / self.ztv_frame.zoom_factor
        ylim = (self.center.y - halfsize, self.center.y + halfsize)
        self.axes.set_ylim(ylim)
        self.figure.canvas.draw()  # bulk of time in method is spent in this line: TODO: look for ways to make faster
        send_change_message = True
        if xlim == self.xlim and ylim == self.ylim:
            send_change_message = False
        self.xlim, self.ylim = xlim, ylim
        if send_change_message:
            wx.CallAfter(pub.sendMessage, 'primary-xy-limits-changed', msg=None)
        return {'xlim':xlim, 'ylim':ylim}
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def on_button_press(self, event):
        if event.button == 1:  # left button
            if self.cursor_mode == 'Zoom':
                if event.dblclick:
                    self.center = wx.RealPoint(event.xdata, event.ydata)
                    self.ztv_frame.zoom_factor /= 2.
                    self.set_and_get_xy_limits()
                else:
                    self.zoom_start_timestamp = time.time()
                    self.zoom_rect = Rectangle((event.xdata, event.ydata), 0, 0,
                                               color='orange', fill=False, zorder=100)
                    self.axes.add_patch(self.zoom_rect)
                    self.figure.canvas.draw()
            elif self.cursor_mode == 'Pan':
                self.center = wx.RealPoint(event.xdata, event.ydata)
                self.set_and_get_xy_limits()
            else:
                if (self.available_cursor_modes.has_key(self.cursor_mode) and
                    self.available_cursor_modes[self.cursor_mode].has_key('on_button_press')):
                    self.available_cursor_modes[self.cursor_mode]['on_button_press'](event)
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def __init__(self, parent, size=wx.Size(128,128), dpi=None, **kwargs):
        self.size = size
        self.dragging_curview_is_active = False
        wx.Panel.__init__(self, parent, wx.ID_ANY, wx.DefaultPosition, size, 0, **kwargs)
        self.ztv_frame = self.GetTopLevelParent()
        self.figure = Figure(None, dpi)
        self.axes = self.figure.add_axes([0., 0., 1., 1.])
        self.curview_rectangle = Rectangle((0, 0), 1, 1, color='orange', fill=False, zorder=100)
        self.axes.add_patch(self.curview_rectangle)
        self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
        self.overview_zoom_factor = 1.
        self._SetSize()
        self.set_xy_limits()
        self.axes_widget = AxesWidget(self.figure.gca())
        self.axes_widget.connect_event('button_press_event', self.on_button_press)
        self.axes_widget.connect_event('button_release_event', self.on_button_release)
        self.axes_widget.connect_event('motion_notify_event', self.on_motion)
        pub.subscribe(self.redraw_overview_image, 'redraw-image')   
        pub.subscribe(self.redraw_box, 'primary-xy-limits-changed')
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def redraw_overview_image(self, msg=None):
        if msg is True or self.ztv_frame._pause_redraw_image:
            return
        if hasattr(self, 'axes_image'):
            if self.axes_image in self.axes.images:
                self.axes.images.remove(self.axes_image)
        # note that following is not an actual rebin, but a sub-sampling, which is what matplotlib ultimately
        # would do on its own anyway if we gave it the full image.  But, matplotlib takes longer.  For a 2Kx2K
        # image, this saves almost 0.3sec on a ~2014 MacBookProRetina
        max_rebin_x = float(self.ztv_frame.display_image.shape[1]) / self.size.x
        max_rebin_y = float(self.ztv_frame.display_image.shape[0]) / self.size.y
        rebin_factor = max(1, np.int(np.floor(min([max_rebin_x, max_rebin_y]))))
        self.axes_image = self.axes.imshow(self.ztv_frame.normalize(self.ztv_frame.display_image)[::rebin_factor, 
                                                                                                  ::rebin_factor],
                                           interpolation='Nearest', vmin=0., vmax=1.,
                                           extent=[0., self.ztv_frame.display_image.shape[1], 
                                                   self.ztv_frame.display_image.shape[0], 0.],
                                           cmap=self.ztv_frame.get_cmap_to_display(), zorder=0)
        clear_ticks_and_frame_from_axes(self.axes)
        self.set_xy_limits()
        self.figure.canvas.draw()
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def redraw_overplot_on_image(self, msg=None):
        if self.primary_image_patch is not None:
            self.ztv_frame.primary_image_panel.axes.patches.remove(self.primary_image_patch)
        if self.start_pt == self.end_pt:
            path = Path([self.start_pt, self.start_pt + (0.5, 0.),
                         self.start_pt, self.start_pt + (-0.5, 0.), 
                         self.start_pt, self.start_pt + (0., 0.5), 
                         self.start_pt, self.start_pt + (0., -0.5), self.start_pt], 
                        [Path.MOVETO, Path.LINETO, Path.LINETO, Path.LINETO, Path.LINETO, 
                         Path.LINETO, Path.LINETO, Path.LINETO, Path.LINETO])
        else:
            path = Path([self.start_pt, self.end_pt], [Path.MOVETO, Path.LINETO])
        self.primary_image_patch = PathPatch(path, color='magenta', lw=1)
        self.ztv_frame.primary_image_panel.axes.add_patch(self.primary_image_patch)
        self.ztv_frame.primary_image_panel.figure.canvas.draw()
        self.hideshow_button.SetLabel(u"Hide")
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def on_button_press(self, event):
        if event.button == 1:  # left button
            if self.cursor_mode == 'Zoom':
                if event.dblclick:
                    self.center = wx.RealPoint(event.xdata, event.ydata)
                    self.ztv_frame.zoom_factor /= 2.
                    self.set_and_get_xy_limits()
                else:
                    self.zoom_start_timestamp = time.time()
                    self.zoom_rect = Rectangle((event.xdata, event.ydata), 0, 0,
                                               color='orange', fill=False, zorder=100)
                    self.axes.add_patch(self.zoom_rect)
                    self.figure.canvas.draw()
            elif self.cursor_mode == 'Pan':
                self.center = wx.RealPoint(event.xdata, event.ydata)
                self.set_and_get_xy_limits()
            else:
                if (self.available_cursor_modes.has_key(self.cursor_mode) and
                    self.available_cursor_modes[self.cursor_mode].has_key('on_button_press')):
                    self.available_cursor_modes[self.cursor_mode]['on_button_press'](event)
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def on_right_down(self, event):
        if self.popup_menu_needs_rebuild or self.popup_menu is None:
            self.init_popup_menu()
        for cursor_mode in self.cursor_mode_to_eventID:
            self.popup_menu.Check(self.cursor_mode_to_eventID[cursor_mode], False)
        self.popup_menu.Check(self.cursor_mode_to_eventID[self.cursor_mode], True)
        for cmap in self.ztv_frame.available_cmaps:
            self.popup_menu.Check(self.cmap_to_eventID[cmap], False)
        self.popup_menu.Check(self.cmap_to_eventID[self.ztv_frame.cmap], True)
        for scaling in self.ztv_frame.available_scalings:
            self.popup_menu.Check(self.scaling_to_eventID[scaling], False)
        self.popup_menu.Check(self.scaling_to_eventID[self.ztv_frame.scaling], True)
        if self.ztv_frame.cur_fits_hdulist is None:
            self.popup_menu.Enable(self.popup_menu_cur_fits_header_eventID, False)
        else:
            self.popup_menu.Enable(self.popup_menu_cur_fits_header_eventID, True)
        self.figure.canvas.PopupMenuXY(self.popup_menu, event.GetX() + 8,  event.GetY() + 8)
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def __init__(self, parent, size=wx.Size(128,128), dpi=None, **kwargs):
        self.size = size
        self.dragging_curview_is_active = False
        wx.Panel.__init__(self, parent, wx.ID_ANY, wx.DefaultPosition, size, 0, **kwargs)
        self.ztv_frame = self.GetTopLevelParent()
        self.figure = Figure(None, dpi)
        self.axes = self.figure.add_axes([0., 0., 1., 1.])
        self.curview_rectangle = Rectangle((0, 0), 1, 1, color='orange', fill=False, zorder=100)
        self.axes.add_patch(self.curview_rectangle)
        self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
        self.overview_zoom_factor = 1.
        self._SetSize()
        self.set_xy_limits()
        self.axes_widget = AxesWidget(self.figure.gca())
        self.axes_widget.connect_event('button_press_event', self.on_button_press)
        self.axes_widget.connect_event('button_release_event', self.on_button_release)
        self.axes_widget.connect_event('motion_notify_event', self.on_motion)
        pub.subscribe(self.redraw_overview_image, 'redraw-image')   
        pub.subscribe(self.redraw_box, 'primary-xy-limits-changed')
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def redraw_overview_image(self, msg=None):
        if msg is True or self.ztv_frame._pause_redraw_image:
            return
        if hasattr(self, 'axes_image'):
            if self.axes_image in self.axes.images:
                self.axes.images.remove(self.axes_image)
        # note that following is not an actual rebin, but a sub-sampling, which is what matplotlib ultimately
        # would do on its own anyway if we gave it the full image.  But, matplotlib takes longer.  For a 2Kx2K
        # image, this saves almost 0.3sec on a ~2014 MacBookProRetina
        max_rebin_x = float(self.ztv_frame.display_image.shape[1]) / self.size.x
        max_rebin_y = float(self.ztv_frame.display_image.shape[0]) / self.size.y
        rebin_factor = max(1, np.int(np.floor(min([max_rebin_x, max_rebin_y]))))
        self.axes_image = self.axes.imshow(self.ztv_frame.normalize(self.ztv_frame.display_image)[::rebin_factor, 
                                                                                                  ::rebin_factor],
                                           interpolation='Nearest', vmin=0., vmax=1.,
                                           extent=[0., self.ztv_frame.display_image.shape[1], 
                                                   self.ztv_frame.display_image.shape[0], 0.],
                                           cmap=self.ztv_frame.get_cmap_to_display(), zorder=0)
        clear_ticks_and_frame_from_axes(self.axes)
        self.set_xy_limits()
        self.figure.canvas.draw()
项目:smhr    作者:andycasey    | 项目源码 | 文件源码
def _interactive_zoom_press(self, event):
        """
        Right-mouse button pressed in axis.

        :param event:
            A matplotlib event.
        """

        if event.button != 3 or event.inaxes is None:
            return None

        self._interactive_zoom_initial_bounds = [event.xdata, event.ydata]
        self._interactive_zoom_axis_index = self.figure.axes.index(event.inaxes)

        # Create lines if needed
        if self._interactive_zoom_axis_index not in self._right_click_zoom_box:
            self._right_click_zoom_box[self._interactive_zoom_axis_index] \
                = event.inaxes.plot([np.nan], [np.nan], "k:")[0]

        # Create zoom box signal
        self._interactive_zoom_box_signal = (
            time.time(),
            self.mpl_connect("motion_notify_event", self._update_interactive_zoom)
        )
        return None
项目:PaleoView    作者:GlobalEcologyLab    | 项目源码 | 文件源码
def __init__(self, canvas, num, window):
        FigureManagerBase.__init__(self, canvas, num)
        self.window = window
        self.window.withdraw()
        self.set_window_title("Figure %d" % num)
        self.canvas = canvas
        self._num =  num
        _, _, w, h = canvas.figure.bbox.bounds
        w, h = int(w), int(h)
        self.window.minsize(int(w*3/4),int(h*3/4))
        if matplotlib.rcParams['toolbar']=='classic':
            self.toolbar = NavigationToolbar( canvas, self.window )
        elif matplotlib.rcParams['toolbar']=='toolbar2':
            self.toolbar = NavigationToolbar2TkAgg( canvas, self.window )
        else:
            self.toolbar = None
        if self.toolbar is not None:
            self.toolbar.update()
        self.canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
        self._shown = False

        def notify_axes_change(fig):
            'this will be called whenever the current axes is changed'
            if self.toolbar != None: self.toolbar.update()
        self.canvas.figure.add_axobserver(notify_axes_change)
项目:PaleoView    作者:GlobalEcologyLab    | 项目源码 | 文件源码
def save_figure(self, *args):
        fs = FileDialog.SaveFileDialog(master=self.window,
                                       title='Save the figure')
        try:
            self.lastDir
        except AttributeError:
            self.lastDir = os.curdir

        fname = fs.go(dir_or_file=self.lastDir) # , pattern="*.png")
        if fname is None: # Cancel
            return

        self.lastDir = os.path.dirname(fname)
        try:
            self.canvas.print_figure(fname)
        except IOError as msg:
            err = '\n'.join(map(str, msg))
            msg = 'Failed to save %s: Error msg was\n\n%s' % (
                fname, err)
            error_msg_tkpaint(msg)
项目:PaleoView    作者:GlobalEcologyLab    | 项目源码 | 文件源码
def _init_toolbar(self):
        xmin, xmax = self.canvas.figure.bbox.intervalx
        height, width = 50, xmax-xmin
        Tk.Frame.__init__(self, master=self.window,
                          width=int(width), height=int(height),
                          borderwidth=2)

        self.update()  # Make axes menu

        for text, tooltip_text, image_file, callback in self.toolitems:
            if text is None:
                # spacer, unhandled in Tk
                pass
            else:
                button = self._Button(text=text, file=image_file,
                                   command=getattr(self, callback))
                if tooltip_text is not None:
                    ToolTip.createToolTip(button, tooltip_text)

        self.message = Tk.StringVar(master=self)
        self._message_label = Tk.Label(master=self, textvariable=self.message)
        self._message_label.pack(side=Tk.RIGHT)
        self.pack(side=Tk.BOTTOM, fill=Tk.X)
项目:PaleoView    作者:GlobalEcologyLab    | 项目源码 | 文件源码
def __init__(self, canvas, num, window):
        FigureManagerBase.__init__(self, canvas, num)
        self.window = window
        self.window.withdraw()
        self.set_window_title("Figure %d" % num)
        self.canvas = canvas
        self._num =  num
        if matplotlib.rcParams['toolbar']=='toolbar2':
            self.toolbar = NavigationToolbar2TkAgg( canvas, self.window )
        else:
            self.toolbar = None
        if self.toolbar is not None:
            self.toolbar.update()
        self.canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
        self._shown = False

        def notify_axes_change(fig):
            'this will be called whenever the current axes is changed'
            if self.toolbar != None: self.toolbar.update()
        self.canvas.figure.add_axobserver(notify_axes_change)
项目:PaleoView    作者:GlobalEcologyLab    | 项目源码 | 文件源码
def _init_toolbar(self):
        xmin, xmax = self.canvas.figure.bbox.intervalx
        height, width = 50, xmax-xmin
        Tk.Frame.__init__(self, master=self.window,
                          width=int(width), height=int(height),
                          borderwidth=2)

        self.update()  # Make axes menu

        for text, tooltip_text, image_file, callback in self.toolitems:
            if text is None:
                # spacer, unhandled in Tk
                pass
            else:
                button = self._Button(text=text, file=image_file,
                                   command=getattr(self, callback))
                if tooltip_text is not None:
                    ToolTip.createToolTip(button, tooltip_text)

        self.message = Tk.StringVar(master=self)
        self._message_label = Tk.Label(master=self, textvariable=self.message)
        self._message_label.pack(side=Tk.RIGHT)
        self.pack(side=Tk.BOTTOM, fill=Tk.X)
项目:PyGEOMET    作者:pygeomet    | 项目源码 | 文件源码
def changeBackground(self,i):
        #self.ColorBar = None
        self.recallProjection = True
        if i == 0:
            self.background = None
            self.clear = True
            #self.axes1[self.slbplt.pNum-1] = None
            #self.slbplt.figure.clear()
        elif i == 1:
            self.background = '.bluemarble'
        elif i == 2:
            self.background = '.shadedrelief'
        else:
            self.background = '.etopo'
        self.calTimeRange = False
        self.pltFxn(self.pNum)
项目:PyGEOMET    作者:pygeomet    | 项目源码 | 文件源码
def resetMapBoundaries(self):
        self.mapBoundary.close()
        self.userGrid = True
        self.south = None
        self.west = None
        self.north = None
        self.east = None
        self.recallProjection = True
        self.figure.clear()
        self.ColorBar = None
        self.cs = None
        self.cs2 = None
        self.barbs = None
        self.vectors = None
        self.vectorkey = None
        self.cs2label = None
        self.domain_average = None
        self.coasts = None
        self.countries = None
        self.states = None
        self.counties = None
        self.meridians = None
        self.parallels = None
        self.calTimeRange = False
        self.pltFxn(self.pNum)
项目:PyGEOMET    作者:pygeomet    | 项目源码 | 文件源码
def __init__(self, plotobj, line):
        self.plotObj = plotobj
        self.points = 0
        self.marker = None
        self.markerEvent = None
        self.startMark = None
        self.visible = False
        self.line = line
        self.userSelects = []
        self.numSelection = 0
        self.mode = 'None'
        self.modeDefs = {'s':'Select', 'S':'Select','d':'Delete','D':'Delete',
                         'v':'View','V': 'View', 'm': 'Marker', 'escape': 'None'}
        self.subMode = 'None'
        self.subModeDefs = {'l':'Line', 'L':'Line','p':'Polygon','P':'Polygon'}
        #self.xs = list(line.get_xdata())
        #self.ys = list(line.get_ydata())
        self.xs = []
        self.ys = []
        #print('init',self.xs)
        print("data selector")
        line.figure.canvas.setFocusPolicy( Qt.ClickFocus )
        line.figure.canvas.setFocus()
        #self.cid = line.figure.canvas.mpl_connect('button_press_event',self)
        self.cid = line.figure.canvas.mpl_connect('key_press_event', self.keyPress)
项目:PyGEOMET    作者:pygeomet    | 项目源码 | 文件源码
def __call__(self, event):

        if event.inaxes!=self.line.axes: return
        if (self.mode == 'None'):
            if event.key in self.modeDefs:
                self.mode = self.modeDefs[event.key]
                print('Mode = ',self.mode)
        if(self.mode == 'Select'):
            if(event.button == 3 ):
                print("Erasing line")
                self.clearSelect()
            else:
                if(event.dblclick ):
                    self.endLine(event)
                else:
                    self.addToLine(event)

        self.line.figure.canvas.draw()
项目:Repobot    作者:Desgard    | 项目源码 | 文件源码
def test_select_figure_formats_kwargs():
    ip = get_ipython()
    kwargs = dict(quality=10, bbox_inches='tight')
    pt.select_figure_formats(ip, 'png', **kwargs)
    formatter = ip.display_formatter.formatters['image/png']
    f = formatter.lookup_by_type(Figure)
    cell = f.__closure__[0].cell_contents
    nt.assert_equal(cell, kwargs)

    # check that the formatter doesn't raise
    fig = plt.figure()
    ax = fig.add_subplot(1,1,1)
    ax.plot([1,2,3])
    plt.draw()
    formatter.enabled = True
    png = formatter(fig)
    assert png.startswith(_PNG)
项目:Repobot    作者:Desgard    | 项目源码 | 文件源码
def getfigs(*fig_nums):
    """Get a list of matplotlib figures by figure numbers.

    If no arguments are given, all available figures are returned.  If the
    argument list contains references to invalid figures, a warning is printed
    but the function continues pasting further figures.

    Parameters
    ----------
    figs : tuple
        A tuple of ints giving the figure numbers of the figures to return.
    """
    from matplotlib._pylab_helpers import Gcf
    if not fig_nums:
        fig_managers = Gcf.get_all_fig_managers()
        return [fm.canvas.figure for fm in fig_managers]
    else:
        figs = []
        for num in fig_nums:
            f = Gcf.figs.get(num)
            if f is None:
                print('Warning: figure %s not available.' % num)
            else:
                figs.append(f.canvas.figure)
        return figs
项目:Structural-Engineering    作者:buddyd16    | 项目源码 | 文件源码
def refreshFigure(self):
        x=[]
        y=[]

        if self.lb_coords.size()==0:
            pass
        else:            
            coords_raw = self.lb_coords.get(0,tk.END)
            for line in coords_raw:
                coords = line.split(',')
                x.append(float(coords[0]))
                y.append(float(coords[1]))

            self.line1.set_data(x,y)
            ax = self.canvas.figure.axes[0]
            ax.set_xlim(min(x)-0.5, max(x)+0.5)
            ax.set_ylim(min(y)-0.5, max(y)+0.5)        
            self.canvas.draw()
项目:blender    作者:gastrodia    | 项目源码 | 文件源码
def test_select_figure_formats_kwargs():
    ip = get_ipython()
    kwargs = dict(quality=10, bbox_inches='tight')
    pt.select_figure_formats(ip, 'png', **kwargs)
    formatter = ip.display_formatter.formatters['image/png']
    f = formatter.lookup_by_type(Figure)
    cell = f.__closure__[0].cell_contents
    nt.assert_equal(cell, kwargs)

    # check that the formatter doesn't raise
    fig = plt.figure()
    ax = fig.add_subplot(1,1,1)
    ax.plot([1,2,3])
    plt.draw()
    formatter.enabled = True
    png = formatter(fig)
    assert png.startswith(_PNG)
项目:blender    作者:gastrodia    | 项目源码 | 文件源码
def getfigs(*fig_nums):
    """Get a list of matplotlib figures by figure numbers.

    If no arguments are given, all available figures are returned.  If the
    argument list contains references to invalid figures, a warning is printed
    but the function continues pasting further figures.

    Parameters
    ----------
    figs : tuple
        A tuple of ints giving the figure numbers of the figures to return.
    """
    from matplotlib._pylab_helpers import Gcf
    if not fig_nums:
        fig_managers = Gcf.get_all_fig_managers()
        return [fm.canvas.figure for fm in fig_managers]
    else:
        figs = []
        for num in fig_nums:
            f = Gcf.figs.get(num)
            if f is None:
                print('Warning: figure %s not available.' % num)
            else:
                figs.append(f.canvas.figure)
        return figs
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def update(self, title=None, color=None, fontsize=10):
        """
        Update PlotLabelTitle properties.

        Parameters
        ----------
        title : str
            Title string.
        bcolor : mpl color spec
            Tiles's background color. 
        """

        if title is not None:
            self._text.set_text(title)
        if color is not None:    
            self.figure.set_facecolor(color)
        if fontsize is not None:
            self._text.set_fontsize(fontsize)
项目:python-QuickUI    作者:ac1235    | 项目源码 | 文件源码
def init_ui(self, root):
    self.figure = Figure(figsize=(5,5), dpi=100)
    self.subplot = self.figure.add_subplot(111)
    self.canvas = FigureCanvasTkAgg(self.figure, root)
    self.canvas.show()
    self.canvas.get_tk_widget().pack(fill=tk.BOTH, expand=1)
    toolbar = NavigationToolbar2TkAgg(self.canvas, root)
    toolbar.update()
项目:mav_rtk_gps    作者:ethz-asl    | 项目源码 | 文件源码
def __init__(self, parent_window):
        # Topic Names.
        self.topic_names = self.get_topic_names()

        self.main_label = Label(parent_window, text="RTK Fix Plot", font="Times 14 bold")
        self.main_label.grid(row=0, columnspan=2)

        # Plot for RTK fix.
        self.first_receiver_state_received = False
        self.first_time_receiver_state = 0

        self.figure = Figure(figsize=(figureSizeWidth, figureSizeHeight), dpi=75)

        self.axes_rtk_fix = self.figure.add_subplot(111)
        self.axes_rtk_fix.set_xlabel('Time [s]')
        self.axes_rtk_fix.set_ylabel('RTK Fix')
        self.axes_rtk_fix.grid()
        self.figure.tight_layout()
        self.axes_rtk_fix.set_yticks([0.0, 1.0])

        self.canvas = FigureCanvasTkAgg(self.figure, master=parent_window)
        self.canvas.show()
        self.canvas.get_tk_widget().grid(rowspan=4, columnspan=2)

        # Position data.
        self.odometry_msg_count = 0
        self.time_rtk_fix = deque([], maxlen=maxLengthDequeArray)
        self.rtk_fix = deque([], maxlen=maxLengthDequeArray)
        self.line_rtk_fix = []

        # Subscribe to topics.
        rospy.Subscriber(self.topic_names['piksi_receiver_state'], ReceiverState,
                         self.receiver_state_callback)
项目:mav_rtk_gps    作者:ethz-asl    | 项目源码 | 文件源码
def reset_view_handler(self):

        if not self.first_odometry_received:
            # Init subplots.
            self.axes_position = self.figure.add_subplot(211)
            self.axes_velocity = self.figure.add_subplot(212)

        else:
            # Clear subplots.
            self.axes_position.clear()
            self.axes_velocity.clear()

        # Position.
        self.axes_position.set_xlabel('Time [s]')
        self.axes_position.set_ylabel('Position [m]')
        self.axes_position.grid()

        # Velocity.
        self.axes_velocity.set_xlabel('Time [s]')
        self.axes_velocity.set_ylabel('Velocity [m/s]')
        self.axes_velocity.grid()

        # Position data.
        self.odometry_msg_count = 0
        self.time_odometry = deque([], maxlen=maxLengthDequeArray)
        self.x = deque([], maxlen=maxLengthDequeArray)
        self.y = deque([], maxlen=maxLengthDequeArray)
        self.z = deque([], maxlen=maxLengthDequeArray)
        self.line_x = []
        self.line_y = []
        self.line_z = []

        # Velocity data.
        self.vx = deque([], maxlen=maxLengthDequeArray)
        self.vy = deque([], maxlen=maxLengthDequeArray)
        self.vz = deque([], maxlen=maxLengthDequeArray)
        self.line_vx = []
        self.line_vy = []
        self.line_vz = []

        self.reset_plot_view = True
项目:atoolbox    作者:liweitianux    | 项目源码 | 文件源码
def plot(self, ax, power=None, colormap="jet"):
        """
        Plot the 2D power spectrum with EoR window marked on.
        """
        x = self.k_perp
        y = self.k_los
        y_wedge = self.wedge_edge()
        if power is None:
            title = "EoR Window (fov=%.1f[deg], e=%.1f)" % (self.fov, self.e)
        else:
            title = (r"fov=%.1f[deg], e=%.1f, power=%.4e$\pm$%.4e[%s]" %
                     (self.fov, self.e, power[0], power[1], self.power_unit))

        # data
        mappable = ax.pcolormesh(x[1:], y[1:],
                                 np.log10(self.ps2d[1:, 1:]),
                                 cmap=colormap)
        # EoR window
        ax.axvline(x=self.k_perp_min, color="black",
                   linewidth=2, linestyle="--")
        ax.axvline(x=self.k_perp_max, color="black",
                   linewidth=2, linestyle="--")
        ax.axhline(y=self.k_los_min, color="black",
                   linewidth=2, linestyle="--")
        ax.axhline(y=self.k_los_max, color="black",
                   linewidth=2, linestyle="--")
        ax.plot(x, y_wedge, color="black", linewidth=2, linestyle="--")
        #
        ax.set(xscale="log", yscale="log",
               xlim=(x[1], x[-1]), ylim=(y[1], y[-1]),
               xlabel=r"$k_{\perp}$ [Mpc$^{-1}$]",
               ylabel=r"$k_{||}$ [Mpc$^{-1}$]",
               title=title)
        cb = ax.figure.colorbar(mappable, ax=ax, pad=0.01, aspect=30)
        cb.ax.set_xlabel("[%s]" % self.unit)
        return ax
项目:atoolbox    作者:liweitianux    | 项目源码 | 文件源码
def plot(self, ax, ax_err, colormap="jet"):
        """
        Plot the calculated 2D power spectrum.
        """
        x = self.k_perp
        y = self.k_los

        if self.meanstd:
            title = "2D Power Spectrum (mean)"
            title_err = "Error (standard deviation)"
        else:
            title = "2D Power Spectrum (median)"
            title_err = "Error (1.4826*MAD)"

        # median/mean
        mappable = ax.pcolormesh(x[1:], y[1:],
                                 np.log10(self.ps2d[0, 1:, 1:]),
                                 cmap=colormap)
        vmin, vmax = mappable.get_clim()
        ax.set(xscale="log", yscale="log",
               xlim=(x[1], x[-1]), ylim=(y[1], y[-1]),
               xlabel=r"$k_{\perp}$ [Mpc$^{-1}$]",
               ylabel=r"$k_{||}$ [Mpc$^{-1}$]",
               title=title)
        cb = ax.figure.colorbar(mappable, ax=ax, pad=0.01, aspect=30)
        cb.ax.set_xlabel(r"[%s$^2$ Mpc$^3$]" % self.unit)

        # error
        mappable = ax_err.pcolormesh(x[1:], y[1:],
                                     np.log10(self.ps2d[1, 1:, 1:]),
                                     cmap=colormap)
        mappable.set_clim(vmin, vmax)
        ax_err.set(xscale="log", yscale="log",
                   xlim=(x[1], x[-1]), ylim=(y[1], y[-1]),
                   xlabel=r"$k_{\perp}$ [Mpc$^{-1}$]",
                   ylabel=r"$k_{||}$ [Mpc$^{-1}$]",
                   title=title_err)
        cb = ax_err.figure.colorbar(mappable, ax=ax_err, pad=0.01, aspect=30)
        cb.ax.set_xlabel(r"[%s$^2$ Mpc$^3$]" % self.unit)

        return (ax, ax_err)
项目:PandasDataFrameGUI    作者:bluenote10    | 项目源码 | 文件源码
def __init__(self, parent, columns, df_list_ctrl):
        wx.Panel.__init__(self, parent)

        columns_with_neutral_selection = [''] + list(columns)
        self.columns = columns
        self.df_list_ctrl = df_list_ctrl

        self.figure = Figure(facecolor="white", figsize=(1, 1))
        self.axes = self.figure.add_subplot(111)
        self.canvas = FigureCanvas(self, -1, self.figure)

        chart_toolbar = NavigationToolbar2Wx(self.canvas)

        self.combo_box1 = wx.ComboBox(self, choices=columns_with_neutral_selection, style=wx.CB_READONLY)

        self.Bind(wx.EVT_COMBOBOX, self.on_combo_box_select)

        row_sizer = wx.BoxSizer(wx.HORIZONTAL)
        row_sizer.Add(self.combo_box1, 0, wx.ALL | wx.ALIGN_CENTER, 5)
        row_sizer.Add(chart_toolbar, 0, wx.ALL, 5)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas, 1, flag=wx.EXPAND, border=5)
        sizer.Add(row_sizer)
        self.SetSizer(sizer)
项目:PandasDataFrameGUI    作者:bluenote10    | 项目源码 | 文件源码
def __init__(self, parent, columns, df_list_ctrl):
        wx.Panel.__init__(self, parent)

        columns_with_neutral_selection = [''] + list(columns)
        self.columns = columns
        self.df_list_ctrl = df_list_ctrl

        self.figure = Figure(facecolor="white", figsize=(1, 1))
        self.axes = self.figure.add_subplot(111)
        self.canvas = FigureCanvas(self, -1, self.figure)

        chart_toolbar = NavigationToolbar2Wx(self.canvas)

        self.combo_box1 = wx.ComboBox(self, choices=columns_with_neutral_selection, style=wx.CB_READONLY)
        self.combo_box2 = wx.ComboBox(self, choices=columns_with_neutral_selection, style=wx.CB_READONLY)

        self.Bind(wx.EVT_COMBOBOX, self.on_combo_box_select)

        row_sizer = wx.BoxSizer(wx.HORIZONTAL)
        row_sizer.Add(self.combo_box1, 0, wx.ALL | wx.ALIGN_CENTER, 5)
        row_sizer.Add(self.combo_box2, 0, wx.ALL | wx.ALIGN_CENTER, 5)
        row_sizer.Add(chart_toolbar, 0, wx.ALL, 5)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas, 1, flag=wx.EXPAND, border=5)
        sizer.Add(row_sizer)
        self.SetSizer(sizer)
项目:cadee    作者:kamerlinlab    | 项目源码 | 文件源码
def __init__(self, parent, plotdata, plotdata_files):
        self.parent = parent
        self.plots = plotdata   # example:  { "dgde" : { 0 : QPlotData_instance (from file 1), 1 : QPlotData_instance (from file 2) }, ... }, where 0,1,... are indices of the filenames in plotdata_files
        self.plotdata_files = plotdata_files    #  [ "/home/.../pro/qa.PlotData.pickle", "/home/.../wat/qa.PlotData.pickle" ]
        self.nrows = 1
        self.ncols = 1
        self.blocked_draw = False
        self.subplot_lines = {}
        self.COLORS_ACTIVE = ("#555555","#F75D59","#1589FF", "black", "red", "blue")
        self.COLORS_INACTIVE = ("#aaaaaa","#F7bDb9","#a5a9FF", "#999999", "#FFaaaa", "#aaaaFF")


        self.lb1_entries = ODict()
        for plot_key, plot in self.plots.iteritems():
            self.lb1_entries[ plot.values()[0].title ] = plot_key

        self.lb1 = Tk.Listbox(self.parent, selectmode=Tk.EXTENDED, exportselection=0)

        for plot_title in self.lb1_entries.keys():
            self.lb1.insert(Tk.END, plot_title)

        self.lb1.pack(fill=Tk.Y, side=Tk.LEFT)
        self.lb2 = Tk.Listbox(self.parent, selectmode=Tk.EXTENDED, exportselection=0)
        self.lb2.pack(fill=Tk.Y, side=Tk.LEFT)

        self.figure = Figure(figsize=(5,4), dpi=100)


        self.canvas = FigureCanvasTkAgg(self.figure, master=self.parent)
        self.canvas.get_tk_widget().pack()
        self.canvas._tkcanvas.pack(fill=Tk.BOTH, expand=1)

        self.toolbar = NavigationToolbar2TkAgg( self.canvas, self.parent )
        self.toolbar.update()
        self.canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)

        self.lb1.bind("<<ListboxSelect>>", self.on_select_lb1)
        self.lb2.bind("<<ListboxSelect>>", self.on_select_lb2)
        self.parent.bind("<Configure>", self.on_resize)
项目:cadee    作者:kamerlinlab    | 项目源码 | 文件源码
def draw_legend(self):
        handls = []
        labls = []
        pos = "lower right"
        for i, plotdata_file in enumerate(self.plotdata_files):
            handls.append(mpatches.Patch(color=self.COLORS_ACTIVE[i]))
            labls.append("%d: %s" % (i, plotdata_file))
        self.figure.legend( handls, labls, pos, fontsize="xx-small" )