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


Python matplotlib.interactive方法代码示例

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


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

示例1: switch_backend

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import interactive [as 别名]
def switch_backend(newbackend):
    """
    Switch the default backend.  This feature is **experimental**, and
    is only expected to work switching to an image backend.  e.g., if
    you have a bunch of PostScript scripts that you want to run from
    an interactive ipython session, you may want to switch to the PS
    backend before running them to avoid having a bunch of GUI windows
    popup.  If you try to interactively switch from one GUI backend to
    another, you will explode.

    Calling this command will close all open windows.
    """
    close('all')
    global _backend_mod, new_figure_manager, draw_if_interactive, _show
    matplotlib.use(newbackend, warn=False, force=True)
    from matplotlib.backends import pylab_setup
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:19,代码来源:pyplot.py

示例2: show

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import interactive [as 别名]
def show(*args, **kw):
    """
    Display a figure.

    When running in ipython with its pylab mode, display all
    figures and return to the ipython prompt.

    In non-interactive mode, display all figures and block until
    the figures have been closed; in interactive mode it has no
    effect unless figures were created prior to a change from
    non-interactive to interactive mode (not recommended).  In
    that case it displays the figures but does not block.

    A single experimental keyword argument, *block*, may be
    set to True or False to override the blocking behavior
    described above.
    """
    global _show
    _show(*args, **kw) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:21,代码来源:pyplot.py

示例3: draw

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import interactive [as 别名]
def draw():
    """
    Redraw the current figure.

    This is used in interactive mode to update a figure that
    has been altered using one or more plot object method calls;
    it is not needed if figure modification is done entirely
    with pyplot functions, if a sequence of modifications ends
    with a pyplot function, or if matplotlib is in non-interactive
    mode and the sequence of modifications ends with :func:`show` or
    :func:`savefig`.

    A more object-oriented alternative, given any
    :class:`~matplotlib.figure.Figure` instance, :attr:`fig`, that
    was created using a :mod:`~matplotlib.pyplot` function, is::

        fig.canvas.draw()


    """
    get_current_fig_manager().canvas.draw() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:23,代码来源:pyplot.py

示例4: activate_matplotlib

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import interactive [as 别名]
def activate_matplotlib(backend):
    """Activate the given backend and set interactive to True."""

    import matplotlib
    matplotlib.interactive(True)
    
    # Matplotlib had a bug where even switch_backend could not force
    # the rcParam to update. This needs to be set *before* the module
    # magic of switch_backend().
    matplotlib.rcParams['backend'] = backend

    import matplotlib.pyplot
    matplotlib.pyplot.switch_backend(backend)

    # This must be imported last in the matplotlib series, after
    # backend/interactivity choices have been made
    import matplotlib.pylab as pylab

    pylab.show._needmain = False
    # We need to detect at runtime whether show() is called by the user.
    # For this, we wrap it into a decorator which adds a 'called' flag.
    pylab.draw_if_interactive = flag_calls(pylab.draw_if_interactive) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:24,代码来源:pylabtools.py

示例5: show

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import interactive [as 别名]
def show(*args, **kw):
    """
    Display a figure.
    When running in ipython with its pylab mode, display all
    figures and return to the ipython prompt.

    In non-interactive mode, display all figures and block until
    the figures have been closed; in interactive mode it has no
    effect unless figures were created prior to a change from
    non-interactive to interactive mode (not recommended).  In
    that case it displays the figures but does not block.

    A single experimental keyword argument, *block*, may be
    set to True or False to override the blocking behavior
    described above.
    """
    global _show
    return _show(*args, **kw) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:20,代码来源:pyplot.py

示例6: plotdata

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import interactive [as 别名]
def plotdata(obsmode,spectrum,val,odict,sdict,
             instr,fieldname,outdir,outname):
    isetting=P.isinteractive()
    P.ioff()

    P.clf()
    P.plot(obsmode,val,'.')
    P.ylabel('(pysyn-syn)/syn')
    P.xlabel('obsmode')
    P.title("%s: %s"%(instr,fieldname))
    P.savefig(os.path.join(outdir,outname+'_obsmode.ps'))

    P.clf()
    P.plot(spectrum,val,'.')
    P.ylabel('(pysyn-syn)/syn')
    P.xlabel('spectrum')
    P.title("%s: %s"%(instr,fieldname))
    P.savefig(os.path.join(outdir,outname+'_spectrum.ps'))

    matplotlib.interactive(isetting) 
开发者ID:spacetelescope,项目名称:pysynphot,代码行数:22,代码来源:doscalars.py

示例7: exceptionDecorator

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import interactive [as 别名]
def exceptionDecorator(func):
    def wrapper(*args, **kwargs):
        try:
            isInteractive = plt.isinteractive()

            # switch to non-interactive mode
            #matplotlib.interactive(False)

            ret = func(*args, **kwargs)

            matplotlib.interactive(isInteractive)

            draw_if_interactive()
            return ret
        except Exception as exc:
            # switch back
            matplotlib.interactive(isInteractive)
            raise

    wrapper.__doc__ = func.__doc__

    return wrapper 
开发者ID:segasai,项目名称:astrolibpy,代码行数:24,代码来源:idlplot.py

示例8: show

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import interactive [as 别名]
def show(*args, **kw):
    """
    Display a figure.

    When running in ipython with its pylab mode, display all
    figures and return to the ipython prompt.

    In non-interactive mode, display all figures and block until
    the figures have been closed; in interactive mode it has no
    effect unless figures were created prior to a change from
    non-interactive to interactive mode (not recommended).  In
    that case it displays the figures but does not block.

    A single experimental keyword argument, *block*, may be
    set to True or False to override the blocking behavior
    described above.
    """
    global _show
    return _show(*args, **kw) 
开发者ID:boris-kz,项目名称:CogAlg,代码行数:21,代码来源:pyplot.py

示例9: draw

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import interactive [as 别名]
def draw():
    """Redraw the current figure.

    This is used to update a figure that has been altered, but not
    automatically re-drawn.  If interactive mode is on (:func:`.ion()`), this
    should be only rarely needed, but there may be ways to modify the state of
    a figure without marking it as `stale`.  Please report these cases as
    bugs.

    A more object-oriented alternative, given any
    :class:`~matplotlib.figure.Figure` instance, :attr:`fig`, that
    was created using a :mod:`~matplotlib.pyplot` function, is::

        fig.canvas.draw_idle()
    """
    get_current_fig_manager().canvas.draw_idle() 
开发者ID:boris-kz,项目名称:CogAlg,代码行数:18,代码来源:pyplot.py

示例10: isinteractive

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import interactive [as 别名]
def isinteractive():
    """
    Return status of interactive mode.
    """
    return matplotlib.is_interactive() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:pyplot.py

示例11: ioff

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import interactive [as 别名]
def ioff():
    'Turn interactive mode off.'
    matplotlib.interactive(False) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:5,代码来源:pyplot.py

示例12: ion

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import interactive [as 别名]
def ion():
    'Turn interactive mode on.'
    matplotlib.interactive(True) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:5,代码来源:pyplot.py

示例13: mpl_runner

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import interactive [as 别名]
def mpl_runner(safe_execfile):
    """Factory to return a matplotlib-enabled runner for %run.

    Parameters
    ----------
    safe_execfile : function
      This must be a function with the same interface as the
      :meth:`safe_execfile` method of IPython.

    Returns
    -------
    A function suitable for use as the ``runner`` argument of the %run magic
    function.
    """
    
    def mpl_execfile(fname,*where,**kw):
        """matplotlib-aware wrapper around safe_execfile.

        Its interface is identical to that of the :func:`execfile` builtin.

        This is ultimately a call to execfile(), but wrapped in safeties to
        properly handle interactive rendering."""

        import matplotlib
        import matplotlib.pylab as pylab

        #print '*** Matplotlib runner ***' # dbg
        # turn off rendering until end of script
        is_interactive = matplotlib.rcParams['interactive']
        matplotlib.interactive(False)
        safe_execfile(fname,*where,**kw)
        matplotlib.interactive(is_interactive)
        # make rendering call now, if the user tried to do it
        if pylab.draw_if_interactive.called:
            pylab.draw()
            pylab.draw_if_interactive.called = False

    return mpl_execfile 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:40,代码来源:pylabtools.py

示例14: imwrite_single_annotmatch2

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import interactive [as 别名]
def imwrite_single_annotmatch2(cm, qreq_, aid, fpath, **kwargs):
        """
        users newer rendering based code
        """
        import plottool_ibeis as pt
        import matplotlib as mpl
        # Pop save kwargs from kwargs
        save_keys = ['dpi', 'figsize', 'saveax', 'verbose']
        save_vals = ut.dict_take_pop(kwargs, save_keys, None)
        savekw = dict(zip(save_keys, save_vals))
        was_interactive = mpl.is_interactive()
        if was_interactive:
            mpl.interactive(False)
        # Make new figure
        fnum = pt.ensure_fnum(kwargs.pop('fnum', None))
        # Create figure --- this takes about 19% - 11% of the time depending on settings
        fig = pt.plt.figure(fnum)
        fig.clf()
        #
        # Draw Matches --- this takes about 48% - 67% of the time depending on settings
        # wrapped call to show_matches2
        cm.show_single_annotmatch(qreq_, aid, colorbar_=False, fnum=fnum, **kwargs)
        # Write matplotlib axes to an image
        axes_extents = pt.extract_axes_extents(fig)
        assert len(axes_extents) == 1, 'more than one axes'
        extent = axes_extents[0]
        #with io.BytesIO() as stream:
        # This call takes 23% - 15% of the time depending on settings
        fig.savefig(fpath, bbox_inches=extent, **savekw)
        #stream.seek(0)
        #data = np.fromstring(stream.getvalue(), dtype=np.uint8)
        #image = cv2.imdecode(data, 1)
        # Ensure that this figure will not pop up
        pt.plt.close(fig)
        if was_interactive:
            mpl.interactive(was_interactive)
        #return image 
开发者ID:Erotemic,项目名称:ibeis,代码行数:39,代码来源:chip_match.py


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