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


Python matplotlib.figure方法代码示例

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


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

示例1: __setup_plot

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import figure [as 别名]
def __setup_plot(self):
        figure = Figure(facecolor='lightgrey')

        self._axes = figure.add_subplot(111)
        self._axes.set_title('Spectrum')
        self._axes.set_xlabel('Frequency (MHz)')
        self._axes.set_ylabel('Level (dB)')
        self._axes.autoscale_view(True, True, True)
        self._axes.grid(True)

        self._spectrum, = self._axes.plot([], [], 'b-', label='Spectrum')

        self._canvas = FigureCanvas(self._panelPlot, -1, figure)
        self._canvas.mpl_connect('motion_notify_event', self.__on_motion)

        Legend.__init__(self, self._axes, self._canvas) 
开发者ID:EarToEarOak,项目名称:RF-Monitor,代码行数:18,代码来源:dialog_spectrum.py

示例2: __setup_plot

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import figure [as 别名]
def __setup_plot(self):
        figure = Figure(facecolor='lightgrey')

        self._axes = figure.add_subplot(111)
        self._axes.set_title('Timeline')
        self._axes.set_xlabel('Time')
        self._axes.set_ylabel('Frequency (MHz)')
        self._axes.grid(True)

        locator = AutoDateLocator()
        formatter = AutoDateFormatter(locator)
        self._axes.xaxis.set_major_formatter(formatter)
        self._axes.xaxis.set_major_locator(locator)
        formatter = ScalarFormatter(useOffset=False)
        self._axes.yaxis.set_major_formatter(formatter)
        self._axes.yaxis.set_minor_locator(AutoMinorLocator(10))

        self._canvas = FigureCanvas(self._panelPlot, -1, figure)
        self._canvas.mpl_connect('motion_notify_event', self.__on_motion)

        Legend.__init__(self, self._axes, self._canvas) 
开发者ID:EarToEarOak,项目名称:RF-Monitor,代码行数:23,代码来源:dialog_timeline.py

示例3: make_figure_window

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import figure [as 别名]
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 = NavigationToolbar2Tk(canvas, self.figure_window)
        toolbar.update()
        canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1) 
开发者ID:jni,项目名称:skan,代码行数:21,代码来源:gui.py

示例4: show_da

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import figure [as 别名]
def show_da(out_da, x_array, y_array, title=""):
    nx = len(x_array)
    ny = len(y_array)
    out_da = out_da.reshape(ny,nx)
    xmin, xmax, ymin, ymax = np.min(x_array), np.max(x_array), np.min(y_array), np.max(y_array)
    extent = xmin, xmax, ymin, ymax

    plt.figure(figsize=(10, 7))
    fig1 = plt.contour(out_da, linewidths=2,extent = extent)#, colors = 'r')

    plt.grid(True)
    plt.title(title)
    plt.xlabel("X, m")
    plt.ylabel("Y, m")
    cb = plt.colorbar()
    cb.set_label('Nturns')

    plt.show() 
开发者ID:ocelot-collab,项目名称:ocelot,代码行数:20,代码来源:accelerator.py

示例5: apply

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import figure [as 别名]
def apply(self,  p_array, dz):
        nbins_x = 400
        nbins_y = 400
        interpolation = "bilinear"
        fig = plt.figure( figsize=None)
        ax_xs = plt.subplot(211)

        show_density(p_array.tau() * 1e3, p_array.x() * 1e3, ax=ax_xs, nbins_x=nbins_x, nbins_y=nbins_y,
                     interpolation=interpolation, ylabel='x [mm]',
                     title="Top view", grid=True, show_xtick_label=False, limits=[[0.025, 0.075], [-2, 2]])
        ax_ys = plt.subplot(212, sharex=ax_xs)

        show_density(p_array.tau() * 1e3, p_array.y() * 1e3, ax=ax_ys, nbins_x=nbins_x, nbins_y=nbins_y,
                     interpolation=interpolation, xlabel="s, [mm]", ylabel='y [mm]', nfig=50,
                     title="Side view", figsize=None, grid=True, show_xtick_label=True,limits=[[0.025, 0.075], [-2, 2]])

        dig = str(self.napply)      
        name = "0"*(4 - len(dig)) + dig

        plt.savefig(name)
        self.napply += 1
        plt.clf() 
开发者ID:ocelot-collab,项目名称:ocelot,代码行数:24,代码来源:accelerator.py

示例6: __init__

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import figure [as 别名]
def __init__(self, nrows, ncols,
                 left=None, bottom=None, right=None, top=None,
                 wspace=None, hspace=None,
                 width_ratios=None, height_ratios=None):
        """
        The number of rows and number of columns of the
        grid need to be set. Optionally, the subplot layout parameters
        (e.g., left, right, etc.) can be tuned.
        """
        #self.figure = figure
        self.left=left
        self.bottom=bottom
        self.right=right
        self.top=top
        self.wspace=wspace
        self.hspace=hspace

        GridSpecBase.__init__(self, nrows, ncols,
                              width_ratios=width_ratios,
                              height_ratios=height_ratios)
        #self.set_width_ratios(width_ratios)
        #self.set_height_ratios(height_ratios) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:24,代码来源:gridspec.py

示例7: get_subplot_params

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import figure [as 别名]
def get_subplot_params(self, fig=None):
        """
        return a dictionary of subplot layout parameters. The default
        parameters are from rcParams unless a figure attribute is set.
        """
        from matplotlib.figure import SubplotParams
        import copy
        if fig is None:
            kw = dict([(k, rcParams["figure.subplot."+k]) \
                       for k in self._AllowedKeys])
            subplotpars = SubplotParams(**kw)
        else:
            subplotpars = copy.copy(fig.subplotpars)

        update_kw = dict([(k, getattr(self, k)) for k in self._AllowedKeys])
        subplotpars.update(**update_kw)

        return subplotpars 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:20,代码来源:gridspec.py

示例8: save_figure

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import figure [as 别名]
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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:22,代码来源:backend_tkagg.py

示例9: _init_toolbar

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import figure [as 别名]
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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:25,代码来源:backend_tkagg.py

示例10: get_renderer

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import figure [as 别名]
def get_renderer(self, cleared=False):
        # Mirrors super.get_renderer, but caches the old one
        # so that we can do things such as prodce a diff image
        # in get_diff_image
        _, _, w, h = self.figure.bbox.bounds
        key = w, h, self.figure.dpi
        try:
            self._lastKey, self._renderer
        except AttributeError:
            need_new_renderer = True
        else:
            need_new_renderer = (self._lastKey != key)

        if need_new_renderer:
            self._renderer = backend_agg.RendererAgg(
                w, h, self.figure.dpi)
            self._last_renderer = backend_agg.RendererAgg(
                w, h, self.figure.dpi)
            self._lastKey = key

        return self._renderer 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:23,代码来源:backend_webagg.py

示例11: __init__

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import figure [as 别名]
def __init__(self, canvas, window):
        """
        figManager is the FigureManagerGTK instance that contains the
        toolbar, with attributes figure, window and drawingArea

        """
        gtk.Toolbar.__init__(self)

        self.canvas = canvas
        # Note: gtk.Toolbar already has a 'window' attribute
        self.win    = window

        self.set_style(gtk.TOOLBAR_ICONS)

        self._create_toolitems_2_4()
        self.update = self._update_2_4
        self.fileselect = FileChooserDialog(
            title='Save the figure',
            parent=self.win,
            filetypes=self.canvas.get_supported_filetypes(),
            default_filetype=self.canvas.get_default_filetype())
        self.show_all()
        self.update() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:25,代码来源:backend_gtk.py

示例12: _update

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import figure [as 别名]
def _update(self):
        'update the active line props from the widgets'
        if not self._inited or not self._updateson: return
        line = self.get_active_line()
        ls = self.get_active_linestyle()
        marker = self.get_active_marker()
        line.set_linestyle(ls)
        line.set_marker(marker)

        button = self.wtree.get_widget('colorbutton_linestyle')
        color = button.get_color()
        r, g, b = [val/65535. for val in (color.red, color.green, color.blue)]
        line.set_color((r,g,b))

        button = self.wtree.get_widget('colorbutton_markerface')
        color = button.get_color()
        r, g, b = [val/65535. for val in (color.red, color.green, color.blue)]
        line.set_markerfacecolor((r,g,b))

        line.figure.canvas.draw() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:22,代码来源:backend_gtk.py

示例13: print_pdf

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import figure [as 别名]
def print_pdf(self, filename, **kwargs):
        image_dpi = kwargs.get('dpi', 72) # dpi to use for images
        self.figure.set_dpi(72)           # there are 72 pdf points to an inch
        width, height = self.figure.get_size_inches()
        if isinstance(filename, PdfPages):
            file = filename._file
        else:
            file = PdfFile(filename)
        try:
            file.newPage(width, height)
            _bbox_inches_restore = kwargs.pop("bbox_inches_restore", None)
            renderer = MixedModeRenderer(self.figure,
                                         width, height, image_dpi, RendererPdf(file, image_dpi),
                                         bbox_inches_restore=_bbox_inches_restore)
            self.figure.draw(renderer)
            renderer.finalize()
        finally:
            if isinstance(filename, PdfPages): # finish off this page
                file.endStream()
            else:            # we opened the file above; now finish it off
                file.close() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:23,代码来源:backend_pdf.py

示例14: figure_enter

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import figure [as 别名]
def figure_enter(event):
    print('figure enter mpl') 
开发者ID:kivy-garden,项目名称:garden.matplotlib,代码行数:4,代码来源:test_backend.py

示例15: figure_leave

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import figure [as 别名]
def figure_leave(event):
    print('figure leaving mpl') 
开发者ID:kivy-garden,项目名称:garden.matplotlib,代码行数:4,代码来源:test_backend.py


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