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


Python Gcf.get_active方法代码示例

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


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

示例1: show

# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_active [as 别名]
def show(block=True, layout="", open_plot=True):
    """
    This show is typically called via pyplot.show.
    In general usage a script will have a sequence of figure creation followed by a pyplot.show which
    effectively blocks and leaves the figures open for the user.
    We suspect this blocking is because the mainloop thread of the GUI is not setDaemon and thus halts
    python termination.
    To simulate this we create a non daemon dummy thread and instruct the user to use Ctrl-C to finish...
    """
    Gcf.get_active().canvas.draw()
    # update the current figure
    # open the browser with the current active figure shown...

    # if not _test and open_plot:
    #     try:
    #         webbrowser.open_new_tab(h5m.url + "/" + str(layout))
    #     except:
    #         print "Failed to open figure page in your browser. Please browse to " + h5m.url + "/" + str(Gcf.get_active().canvas.figure.number)

    if block and not _test:
        print "Showing figures. Hit Ctrl-C to finish script and close figures..."
        try:
            while True:
                time.sleep(1)
        except KeyboardInterrupt:
            if not _quiet:
                print "Shutting down..."
开发者ID:brefsdal,项目名称:peerplot,代码行数:29,代码来源:backend_h5canvas.py

示例2: show

# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_active [as 别名]
def show():
    """ Show all the figures """
    for manager in Gcf.get_all_fig_managers():
        manager.window.show()
    figManager =  Gcf.get_active()
    if figManager != None:
        figManager.canvas.draw()
开发者ID:BackupTheBerlios,项目名称:simuvis4-svn,代码行数:9,代码来源:backend_sv4agg.py

示例3: draw_if_interactive

# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_active [as 别名]
def draw_if_interactive():
    '''Handle whether or not the backend is in interactive mode or not.
    '''
    if matplotlib.is_interactive():
        figManager = Gcf.get_active()
        if figManager:
            figManager.canvas.draw_idle()
开发者ID:kivy-garden,项目名称:garden.matplotlib,代码行数:9,代码来源:backend_kivy.py

示例4: draw_if_interactive

# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_active [as 别名]
def draw_if_interactive():
    """
    Is called after every pylab drawing command
    """
    if matplotlib.is_interactive():
        figManager =  Gcf.get_active()
        if figManager is not None:
            figManager.canvas.draw_idle()
开发者ID:AndreI11,项目名称:SatStressGui,代码行数:10,代码来源:backend_gtk.py

示例5: ignore

# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_active [as 别名]
	def ignore(self, event):
		if event.inaxes != self.ax:
			return True
		elif 'zoom' in Gcf.get_active().toolbar.mode:
			return True
		elif event.name == 'pick_event':
			return True
		return False
开发者ID:xlougeo,项目名称:aimbat,代码行数:10,代码来源:plotutils.py

示例6: draw_if_interactive

# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_active [as 别名]
def draw_if_interactive():
    try:
        import matplotlib
        from matplotlib._pylab_helpers import Gcf
        if matplotlib.is_interactive():
            figManager = Gcf.get_active()
            if figManager is not None and figManager.canvas and figManager.canvas.figure:
                retval = display(figManager.canvas.figure, overwrite=(not pyplot_dict["new_plot"]))
                pyplot_dict["new_plot"] = False
                return retval
    except Exception:
        pass
开发者ID:blackhat06,项目名称:graphterm,代码行数:14,代码来源:gmatplot.py

示例7: _show

# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_active [as 别名]
def _show():
    from matplotlib._pylab_helpers import Gcf
    active_manager = Gcf.get_active()
    if active_manager:
        import console
        import tempfile
        screen_width, screen_height = console._get_screen_size()
        compact = screen_width < 768
        dpi = 160 if not compact else 66.2
        tmp = tempfile.mktemp(suffix='.png')
        active_manager.canvas.figure.savefig(tmp, dpi=dpi)
        console.show_image(tmp)
开发者ID:Tkizzy,项目名称:PythonistaAppTemplate,代码行数:14,代码来源:backend_agg.py

示例8: savefig

# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_active [as 别名]
    def savefig(self, figure=None, **kwargs):
        """
        Saves a :class:`~matplotlib.figure.Figure` to this file as a new page.

        Any other keyword arguments are passed to
        :meth:`~matplotlib.figure.Figure.savefig`.

        Parameters
        ----------

        figure : :class:`~matplotlib.figure.Figure` or int, optional
            Specifies what figure is saved to file. If not specified, the
            active figure is saved. If a :class:`~matplotlib.figure.Figure`
            instance is provided, this figure is saved. If an int is specified,
            the figure instance to save is looked up by number.
        """
        if not isinstance(figure, Figure):
            if figure is None:
                manager = Gcf.get_active()
            else:
                manager = Gcf.get_fig_manager(figure)
            if manager is None:
                raise ValueError("No figure {}".format(figure))
            figure = manager.canvas.figure

        try:
            orig_canvas = figure.canvas
            figure.canvas = FigureCanvasPgf(figure)

            width, height = figure.get_size_inches()
            if self._n_figures == 0:
                self._write_header(width, height)
            else:
                # \pdfpagewidth and \pdfpageheight exist on pdftex, xetex, and
                # luatex<0.85; they were renamed to \pagewidth and \pageheight
                # on luatex>=0.85.
                self._file.write(
                    br'\newpage'
                    br'\ifdefined\pdfpagewidth\pdfpagewidth'
                    br'\else\pagewidth\fi=%ain'
                    br'\ifdefined\pdfpageheight\pdfpageheight'
                    br'\else\pageheight\fi=%ain'
                    b'%%\n' % (width, height)
                )

            figure.savefig(self._file, format="pgf", **kwargs)
            self._n_figures += 1
        finally:
            figure.canvas = orig_canvas
开发者ID:endolith,项目名称:matplotlib,代码行数:51,代码来源:backend_pgf.py

示例9: draw_if_interactive

# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_active [as 别名]
def draw_if_interactive():
    """
    If interactive mode is on, this allows for updating properties of
    the figure when each new plotting command is called.
    """
    manager = Gcf.get_active()
    interactive = matplotlib.is_interactive()
    angular = mpl_config.get('angular')
    
    # Don't bother continuing if we aren't in interactive mode
    # or if there are no active figures. Also pointless to continue
    # in angular mode as we don't want to reshow the figure.
    if not interactive or angular or manager is None:
        return
        
    # Allow for figure to be reshown if close is false since
    # this function call implies that it has been updated
    if not mpl_config.get('close'):
        manager._shown = False
开发者ID:ollie314,项目名称:incubator-zeppelin,代码行数:21,代码来源:backend_zinline.py

示例10: show

# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_active [as 别名]
def show( mainloop=True ):
    """
    Show all the figures and enter the qt main loop
    This should be the last line of your script
    """
    for manager in Gcf.get_all_fig_managers():
        manager.window.show()
        
    if DEBUG: print 'Inside show'
    figManager =  Gcf.get_active()
    if figManager != None:
        figManager.canvas.draw()
        #if ( createQApp ):
        #   qtapplication.setMainWidget( figManager.canvas )

    if mainloop and createQApp:
        qt.QObject.connect( qtapplication, qt.SIGNAL( "lastWindowClosed()" ),
                            qtapplication, qt.SLOT( "quit()" ) )
        qtapplication.exec_loop()    
开发者ID:jardous,项目名称:anasig,代码行数:21,代码来源:backend_qt.py

示例11: draw_if_interactive

# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_active [as 别名]
def draw_if_interactive():
    """
    Is called after every pylab drawing command
    """
    # signal that the current active figure should be sent at the end of
    # execution.  Also sets the _draw_called flag, signaling that there will be
    # something to send.  At the end of the code execution, a separate call to
    # flush_figures() will act upon these values
    manager = Gcf.get_active()
    if manager is None:
        return
    fig = manager.canvas.figure

    # Hack: matplotlib FigureManager objects in interacive backends (at least
    # in some of them) monkeypatch the figure object and add a .show() method
    # to it.  This applies the same monkeypatch in order to support user code
    # that might expect `.show()` to be part of the official API of figure
    # objects.
    # For further reference:
    # https://github.com/ipython/ipython/issues/1612
    # https://github.com/matplotlib/matplotlib/issues/835

    if not hasattr(fig, 'show'):
        # Queue up `fig` for display
        fig.show = lambda *a: display(fig, metadata=_fetch_figure_metadata(fig))

    # If matplotlib was manually set to non-interactive mode, this function
    # should be a no-op (otherwise we'll generate duplicate plots, since a user
    # who set ioff() manually expects to make separate draw/show calls).
    if not matplotlib.is_interactive():
        return

    # ensure current figure will be drawn, and each subsequent call
    # of draw_if_interactive() moves the active figure to ensure it is
    # drawn last
    try:
        show._to_draw.remove(fig)
    except ValueError:
        # ensure it only appears in the draw list once
        pass
    # Queue up the figure for drawing in next show() call
    show._to_draw.append(fig)
    show._draw_called = True
开发者ID:ipython,项目名称:ipykernel,代码行数:45,代码来源:backend_inline.py

示例12: draw_if_interactive

# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_active [as 别名]
def draw_if_interactive():
    """
    Is called after every pylab drawing command
    """
    # signal that the current active figure should be sent at the end of execution.
    # Also sets the _draw_called flag, signaling that there will be something to send.
    # At the end of the code execution, a separate call to flush_figures()
    # will act upon these values
    
    fig = Gcf.get_active().canvas.figure
    
    # ensure current figure will be drawn, and each subsequent call
    # of draw_if_interactive() moves the active figure to ensure it is
    # drawn last
    try:
        show._to_draw.remove(fig)
    except ValueError:
        # ensure it only appears in the draw list once
        pass
    show._to_draw.append(fig)
    show._draw_called = True
开发者ID:daf,项目名称:ipython,代码行数:23,代码来源:backend_inline.py

示例13: awakeFromNib

# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_active [as 别名]
    def awakeFromNib(self):
        # Get a reference to the active canvas
        NSApp().setDelegate_(self)
        self.app = NSApp()
        self.canvas = Gcf.get_active().canvas
        self.plotView.canvas = self.canvas
        self.canvas.plotView = self.plotView

        self.plotWindow.setAcceptsMouseMovedEvents_(True)
        self.plotWindow.makeKeyAndOrderFront_(self)
        self.plotWindow.setDelegate_(self)#.plotView)

        self.plotView.setImageFrameStyle_(NSImageFrameGroove)
        self.plotView.image_ = NSImage.alloc().initWithSize_((0,0))
        self.plotView.setImage_(self.plotView.image_)

        # Make imageview first responder for key events
        self.plotWindow.makeFirstResponder_(self.plotView)

        # Force the first update
        self.plotView.windowDidResize_(self)
开发者ID:CTPUG,项目名称:matplotlib-py3,代码行数:23,代码来源:backend_cocoaagg.py

示例14: savefig

# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_active [as 别名]
    def savefig(self, figure=None, **kwargs):
        """
        Saves a :class:`~matplotlib.figure.Figure` to this file as a new page.

        Any other keyword arguments are passed to
        :meth:`~matplotlib.figure.Figure.savefig`.

        Parameters
        ----------

        figure : :class:`~matplotlib.figure.Figure` or int, optional
            Specifies what figure is saved to file. If not specified, the
            active figure is saved. If a :class:`~matplotlib.figure.Figure`
            instance is provided, this figure is saved. If an int is specified,
            the figure instance to save is looked up by number.
        """
        if not isinstance(figure, Figure):
            if figure is None:
                manager = Gcf.get_active()
            else:
                manager = Gcf.get_fig_manager(figure)
            if manager is None:
                raise ValueError("No figure {}".format(figure))
            figure = manager.canvas.figure

        try:
            orig_canvas = figure.canvas
            figure.canvas = FigureCanvasPgf(figure)

            width, height = figure.get_size_inches()
            if self._n_figures == 0:
                self._write_header(width, height)
            else:
                self._file.write(self._build_newpage_command(width, height))

            figure.savefig(self._file, format="pgf", **kwargs)
            self._n_figures += 1
        finally:
            figure.canvas = orig_canvas
开发者ID:souravsingh,项目名称:matplotlib,代码行数:41,代码来源:backend_pgf.py

示例15: draw_if_interactive

# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_active [as 别名]
def draw_if_interactive():
    if matplotlib.is_interactive():
        figManager =  Gcf.get_active()
        if figManager is not None:
            figManager.show()
开发者ID:astraw,项目名称:matplotlib,代码行数:7,代码来源:backend_tkagg.py


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