當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。