Python matplotlib.is_interactive() Examples
The following are 30
code examples of matplotlib.is_interactive().
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 also want to check out all available functions/classes of the module
matplotlib
, or try the search function
.
Example #1
Source File: backend_nbagg.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def show(*args, **kwargs): ## TODO: something to do when keyword block==False ? from matplotlib._pylab_helpers import Gcf managers = Gcf.get_all_fig_managers() if not managers: return interactive = is_interactive() for manager in managers: manager.show() # plt.figure adds an event which puts the figure in focus # in the activeQue. Disable this behaviour, as it results in # figures being put as the active figure after they have been # shown, even in non-interactive mode. if hasattr(manager, '_cidgcf'): manager.canvas.mpl_disconnect(manager._cidgcf) if not interactive and manager in Gcf._activeQue: Gcf._activeQue.remove(manager)
Example #2
Source File: backend_nbagg.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def connection_info(): """ Return a string showing the figure and connection status for the backend. This is intended as a diagnostic tool, and not for general use. """ result = [ '{fig} - {socket}'.format( fig=(manager.canvas.figure.get_label() or "Figure {}".format(manager.num)), socket=manager.web_sockets) for manager in Gcf.get_all_fig_managers() ] if not is_interactive(): result.append('Figures pending show: {}'.format(len(Gcf._activeQue))) return '\n'.join(result) # Note: Version 3.2 and 4.x icons # http://fontawesome.io/3.2.1/icons/ # http://fontawesome.io/ # the `fa fa-xxx` part targets font-awesome 4, (IPython 3.x) # the icon-xxx targets font awesome 3.21 (IPython 2.x)
Example #3
Source File: backend_gtk.py From neural-network-animation with MIT License | 6 votes |
def destroy(self, *args): if _debug: print('FigureManagerGTK.%s' % fn_name()) if hasattr(self, 'toolbar') and self.toolbar is not None: self.toolbar.destroy() if hasattr(self, 'vbox'): self.vbox.destroy() if hasattr(self, 'window'): self.window.destroy() if hasattr(self, 'canvas'): self.canvas.destroy() self.__dict__.clear() #Is this needed? Other backends don't have it. if Gcf.get_num_fig_managers()==0 and \ not matplotlib.is_interactive() and \ gtk.main_level() >= 1: gtk.main_quit()
Example #4
Source File: backend_macosx.py From neural-network-animation with MIT License | 6 votes |
def __init__(self, canvas, num): FigureManagerBase.__init__(self, canvas, num) title = "Figure %d" % num _macosx.FigureManager.__init__(self, canvas, title) if rcParams['toolbar']=='toolbar2': self.toolbar = NavigationToolbar2Mac(canvas) else: self.toolbar = None if self.toolbar is not None: self.toolbar.update() def notify_axes_change(fig): 'this will be called whenever the current axes is changed' if self.toolbar != None: self.toolbar.update() self.canvas.figure.add_axobserver(notify_axes_change) if matplotlib.is_interactive(): self.show()
Example #5
Source File: backend_nbagg.py From neural-network-animation with MIT License | 6 votes |
def __call__(self, block=None): from matplotlib._pylab_helpers import Gcf from matplotlib import is_interactive managers = Gcf.get_all_fig_managers() if not managers: return interactive = is_interactive() for manager in managers: manager.show() # plt.figure adds an event which puts the figure in focus # in the activeQue. Disable this behaviour, as it results in # figures being put as the active figure after they have been # shown, even in non-interactive mode. if hasattr(manager, '_cidgcf'): manager.canvas.mpl_disconnect(manager._cidgcf) if not interactive and manager in Gcf._activeQue: Gcf._activeQue.remove(manager)
Example #6
Source File: backend_nbagg.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def connection_info(): """ Return a string showing the figure and connection status for the backend. This is intended as a diagnostic tool, and not for general use. """ result = [] for manager in Gcf.get_all_fig_managers(): fig = manager.canvas.figure result.append('{0} - {0}'.format((fig.get_label() or "Figure {0}".format(manager.num)), manager.web_sockets)) if not is_interactive(): result.append('Figures pending show: {0}'.format(len(Gcf._activeQue))) return '\n'.join(result) # Note: Version 3.2 and 4.x icons # http://fontawesome.io/3.2.1/icons/ # http://fontawesome.io/ # the `fa fa-xxx` part targets font-awesome 4, (IPython 3.x) # the icon-xxx targets font awesome 3.21 (IPython 2.x)
Example #7
Source File: backend_nbagg.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def show(*args, **kwargs): ## TODO: something to do when keyword block==False ? from matplotlib._pylab_helpers import Gcf managers = Gcf.get_all_fig_managers() if not managers: return interactive = is_interactive() for manager in managers: manager.show() # plt.figure adds an event which puts the figure in focus # in the activeQue. Disable this behaviour, as it results in # figures being put as the active figure after they have been # shown, even in non-interactive mode. if hasattr(manager, '_cidgcf'): manager.canvas.mpl_disconnect(manager._cidgcf) if not interactive and manager in Gcf._activeQue: Gcf._activeQue.remove(manager)
Example #8
Source File: backend_gtk.py From Computable with MIT License | 6 votes |
def destroy(self, *args): if _debug: print('FigureManagerGTK.%s' % fn_name()) if hasattr(self, 'toolbar') and self.toolbar is not None: self.toolbar.destroy() if hasattr(self, 'vbox'): self.vbox.destroy() if hasattr(self, 'window'): self.window.destroy() if hasattr(self, 'canvas'): self.canvas.destroy() self.__dict__.clear() #Is this needed? Other backends don't have it. if Gcf.get_num_fig_managers()==0 and \ not matplotlib.is_interactive() and \ gtk.main_level() >= 1: gtk.main_quit()
Example #9
Source File: backend_gtk.py From matplotlib-4-abaqus with MIT License | 6 votes |
def destroy(self, *args): if _debug: print('FigureManagerGTK.%s' % fn_name()) if hasattr(self, 'toolbar') and self.toolbar is not None: self.toolbar.destroy() if hasattr(self, 'vbox'): self.vbox.destroy() if hasattr(self, 'window'): self.window.destroy() if hasattr(self, 'canvas'): self.canvas.destroy() self.__dict__.clear() #Is this needed? Other backends don't have it. if Gcf.get_num_fig_managers()==0 and \ not matplotlib.is_interactive() and \ gtk.main_level() >= 1: gtk.main_quit()
Example #10
Source File: backend_nbagg.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def connection_info(): """ Return a string showing the figure and connection status for the backend. This is intended as a diagnostic tool, and not for general use. """ result = [] for manager in Gcf.get_all_fig_managers(): fig = manager.canvas.figure result.append('{0} - {0}'.format((fig.get_label() or "Figure {0}".format(manager.num)), manager.web_sockets)) if not is_interactive(): result.append('Figures pending show: {0}'.format(len(Gcf._activeQue))) return '\n'.join(result) # Note: Version 3.2 and 4.x icons # http://fontawesome.io/3.2.1/icons/ # http://fontawesome.io/ # the `fa fa-xxx` part targets font-awesome 4, (IPython 3.x) # the icon-xxx targets font awesome 3.21 (IPython 2.x)
Example #11
Source File: backend_gtk.py From neural-network-animation with MIT License | 5 votes |
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()
Example #12
Source File: backend_nbagg.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def new_figure_manager_given_figure(num, figure): canvas = FigureCanvasNbAgg(figure) manager = FigureManagerNbAgg(canvas, num) if is_interactive(): manager.show() figure.canvas.draw_idle() canvas.mpl_connect('close_event', lambda event: Gcf.destroy(num)) return manager
Example #13
Source File: backend_nbagg.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def new_figure_manager_given_figure(num, figure): canvas = FigureCanvasNbAgg(figure) manager = FigureManagerNbAgg(canvas, num) if is_interactive(): manager.show() figure.canvas.draw_idle() canvas.mpl_connect('close_event', lambda event: Gcf.destroy(num)) return manager
Example #14
Source File: pyplot.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def _auto_draw_if_interactive(fig, val): """ This is an internal helper function for making sure that auto-redrawing works as intended in the plain python repl. Parameters ---------- fig : Figure A figure object which is assumed to be associated with a canvas """ if val and matplotlib.is_interactive() and not fig.canvas.is_saving(): fig.canvas.draw_idle()
Example #15
Source File: _backend_tk.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def new_figure_manager_given_figure(cls, num, figure): """ Create a new figure manager instance for the given figure. """ with _restore_foreground_window_at_end(): window = Tk.Tk(className="matplotlib") window.withdraw() # Put a mpl icon on the window rather than the default tk icon. # Tkinter doesn't allow colour icons on linux systems, but tk>=8.5 # has a iconphoto command which we call directly. Source: # http://mail.python.org/pipermail/tkinter-discuss/2006-November/000954.html icon_fname = os.path.join( rcParams['datapath'], 'images', 'matplotlib.ppm') icon_img = Tk.PhotoImage(file=icon_fname, master=window) try: window.iconphoto(False, icon_img) except Exception as exc: # log the failure (due e.g. to Tk version), but carry on _log.info('Could not load matplotlib icon: %s', exc) canvas = cls.FigureCanvas(figure, master=window) manager = cls.FigureManager(canvas, num, window) if matplotlib.is_interactive(): manager.show() canvas.draw_idle() return manager
Example #16
Source File: backend_wx.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def new_figure_manager_given_figure(cls, num, figure): frame = cls._frame_class(num, figure) figmgr = frame.get_figure_manager() if matplotlib.is_interactive(): figmgr.frame.Show() figure.canvas.draw_idle() return figmgr
Example #17
Source File: backend_gtk3.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def destroy(self, *args): self.vbox.destroy() self.window.destroy() self.canvas.destroy() if self.toolbar: self.toolbar.destroy() if (Gcf.get_num_fig_managers() == 0 and not matplotlib.is_interactive() and Gtk.main_level() >= 1): Gtk.main_quit()
Example #18
Source File: backend_macosx.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def __init__(self, canvas, num): FigureManagerBase.__init__(self, canvas, num) title = "Figure %d" % num _macosx.FigureManager.__init__(self, canvas, title) if rcParams['toolbar'] == 'toolbar2': self.toolbar = NavigationToolbar2Mac(canvas) else: self.toolbar = None if self.toolbar is not None: self.toolbar.update() if matplotlib.is_interactive(): self.show() self.canvas.draw_idle()
Example #19
Source File: backend_wxagg.py From neural-network-animation with MIT License | 5 votes |
def new_figure_manager_given_figure(num, figure): """ Create a new figure manager instance for the given figure. """ frame = FigureFrameWxAgg(num, figure) figmgr = frame.get_figure_manager() if matplotlib.is_interactive(): figmgr.frame.Show() return figmgr # # agg/wxPython image conversion functions (wxPython >= 2.8) #
Example #20
Source File: backend_gtk3.py From matplotlib-4-abaqus with MIT License | 5 votes |
def destroy(self, *args): if _debug: print 'FigureManagerGTK3.%s' % fn_name() self.vbox.destroy() self.window.destroy() self.canvas.destroy() if self.toolbar: self.toolbar.destroy() self.__dict__.clear() #Is this needed? Other backends don't have it. if Gcf.get_num_fig_managers()==0 and \ not matplotlib.is_interactive() and \ Gtk.main_level() >= 1: Gtk.main_quit()
Example #21
Source File: test_ssnl_plot.py From pysat with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_scatterplot_w_ion(self): """Check if scatterplot generates and resets to interactive mode""" plt.ion() figs = plot.scatterplot(self.testInst, 'longitude', 'latitude', 'slt', [0.0, 24.0]) axes = figs[0].get_axes() assert len(figs) == 1 assert len(axes) == 3 assert mpl.is_interactive()
Example #22
Source File: backend_macosx.py From matplotlib-4-abaqus with MIT License | 5 votes |
def draw_if_interactive(): """ For performance reasons, we don't want to redraw the figure after each draw command. Instead, we mark the figure as invalid, so that it will be redrawn as soon as the event loop resumes via PyOS_InputHook. This function should be called after each draw event, even if matplotlib is not running interactively. """ if matplotlib.is_interactive(): figManager = Gcf.get_active() if figManager is not None: figManager.canvas.invalidate()
Example #23
Source File: backend_tkagg.py From neural-network-animation with MIT License | 5 votes |
def new_figure_manager_given_figure(num, figure): """ Create a new figure manager instance for the given figure. """ _focus = windowing.FocusManager() window = Tk.Tk() window.withdraw() if Tk.TkVersion >= 8.5: # put a mpl icon on the window rather than the default tk icon. Tkinter # doesn't allow colour icons on linux systems, but tk >=8.5 has a iconphoto # command which we call directly. Source: # http://mail.python.org/pipermail/tkinter-discuss/2006-November/000954.html icon_fname = os.path.join(rcParams['datapath'], 'images', 'matplotlib.gif') icon_img = Tk.PhotoImage(file=icon_fname) try: window.tk.call('wm', 'iconphoto', window._w, icon_img) except (SystemExit, KeyboardInterrupt): # re-raise exit type Exceptions raise except: # log the failure, but carry on verbose.report('Could not load matplotlib icon: %s' % sys.exc_info()[1]) canvas = FigureCanvasTkAgg(figure, master=window) figManager = FigureManagerTkAgg(canvas, num, window) if matplotlib.is_interactive(): figManager.show() return figManager
Example #24
Source File: backend_tkagg.py From neural-network-animation with MIT License | 5 votes |
def draw_if_interactive(): if matplotlib.is_interactive(): figManager = Gcf.get_active() if figManager is not None: figManager.show()
Example #25
Source File: backend_nbagg.py From neural-network-animation with MIT License | 5 votes |
def draw_if_interactive(): from matplotlib import is_interactive import matplotlib._pylab_helpers as pylab_helpers if is_interactive(): manager = pylab_helpers.Gcf.get_active() if manager is not None: manager.show()
Example #26
Source File: backend_wx.py From matplotlib-4-abaqus with MIT License | 5 votes |
def new_figure_manager_given_figure(num, figure): """ Create a new figure manager instance for the given figure. """ fig = figure frame = FigureFrameWx(num, fig) figmgr = frame.get_figure_manager() if matplotlib.is_interactive(): figmgr.frame.Show() return figmgr
Example #27
Source File: backend_qt4.py From matplotlib-4-abaqus with MIT License | 5 votes |
def draw_if_interactive(): """ Is called after every pylab drawing command """ if matplotlib.is_interactive(): figManager = Gcf.get_active() if figManager != None: figManager.canvas.draw_idle()
Example #28
Source File: chip_match.py From ibeis with 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 #29
Source File: pyplot.py From matplotlib-4-abaqus with MIT License | 5 votes |
def isinteractive(): """ Return status of interactive mode. """ return matplotlib.is_interactive()
Example #30
Source File: backend_cocoaagg.py From matplotlib-4-abaqus with MIT License | 5 votes |
def draw_if_interactive(): if matplotlib.is_interactive(): figManager = Gcf.get_active() if figManager is not None: figManager.show()