Python matplotlib.interactive() Examples
The following are 30 code examples for showing how to use matplotlib.interactive(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
matplotlib
, or try the search function
.
Example 1
Project: Computable Author: ktraunmueller File: pyplot.py License: MIT License | 6 votes |
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()
Example 2
Project: Computable Author: ktraunmueller File: pyplot.py License: MIT License | 6 votes |
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)
Example 3
Project: Computable Author: ktraunmueller File: pyplot.py License: MIT License | 6 votes |
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()
Example 4
Project: Computable Author: ktraunmueller File: pylabtools.py License: MIT License | 6 votes |
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)
Example 5
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: pyplot.py License: MIT License | 6 votes |
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()
Example 6
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: pyplot.py License: MIT License | 6 votes |
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)
Example 7
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: pyplot.py License: MIT License | 6 votes |
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()
Example 8
Project: neural-network-animation Author: miloharper File: pyplot.py License: MIT License | 6 votes |
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()
Example 9
Project: neural-network-animation Author: miloharper File: pyplot.py License: MIT License | 6 votes |
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)
Example 10
Project: neural-network-animation Author: miloharper File: pyplot.py License: MIT License | 6 votes |
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()
Example 11
Project: GraphicDesignPatternByPython Author: Relph1119 File: pyplot.py License: MIT License | 6 votes |
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)
Example 12
Project: python3_ios Author: holzschu File: pyplot.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
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)
Example 13
Project: pysynphot Author: spacetelescope File: doscalars.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
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)
Example 14
Project: astrolibpy Author: segasai File: idlplot.py License: GNU General Public License v3.0 | 6 votes |
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
Example 15
Project: coffeegrindsize Author: jgagneastro File: pyplot.py License: MIT License | 6 votes |
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)
Example 16
Project: CogAlg Author: boris-kz File: pyplot.py License: MIT License | 6 votes |
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)
Example 17
Project: CogAlg Author: boris-kz File: pyplot.py License: MIT License | 6 votes |
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()
Example 18
Project: twitter-stock-recommendation Author: alvarobartt File: pyplot.py License: MIT License | 6 votes |
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()
Example 19
Project: twitter-stock-recommendation Author: alvarobartt File: pyplot.py License: MIT License | 6 votes |
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)
Example 20
Project: Computable Author: ktraunmueller File: pyplot.py License: MIT License | 5 votes |
def isinteractive(): """ Return status of interactive mode. """ return matplotlib.is_interactive()
Example 21
Project: Computable Author: ktraunmueller File: pyplot.py License: MIT License | 5 votes |
def ioff(): 'Turn interactive mode off.' matplotlib.interactive(False)
Example 22
Project: Computable Author: ktraunmueller File: pyplot.py License: MIT License | 5 votes |
def ion(): 'Turn interactive mode on.' matplotlib.interactive(True)
Example 23
Project: Computable Author: ktraunmueller File: pylabtools.py License: MIT License | 5 votes |
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
Example 24
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: pyplot.py License: MIT License | 5 votes |
def isinteractive(): """ Return status of interactive mode. """ return matplotlib.is_interactive()
Example 25
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: pyplot.py License: MIT License | 5 votes |
def ioff(): 'Turn interactive mode off.' matplotlib.interactive(False)
Example 26
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: pyplot.py License: MIT License | 5 votes |
def ion(): 'Turn interactive mode on.' matplotlib.interactive(True)
Example 27
Project: ibeis Author: Erotemic File: chip_match.py License: Apache License 2.0 | 5 votes |
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
Example 28
Project: neural-network-animation Author: miloharper File: pyplot.py License: MIT License | 5 votes |
def isinteractive(): """ Return status of interactive mode. """ return matplotlib.is_interactive()
Example 29
Project: neural-network-animation Author: miloharper File: pyplot.py License: MIT License | 5 votes |
def ioff(): 'Turn interactive mode off.' matplotlib.interactive(False)
Example 30
Project: neural-network-animation Author: miloharper File: pyplot.py License: MIT License | 5 votes |
def ion(): 'Turn interactive mode on.' matplotlib.interactive(True)