Python matplotlib.pylab.draw_if_interactive() Examples
The following are 21
code examples of matplotlib.pylab.draw_if_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.pylab
, or try the search function
.
Example #1
Source File: pylabtools.py From Computable with 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 #2
Source File: testfuncs.py From Computable with MIT License | 5 votes |
def plot_dt(tri, colors=None): import matplotlib as mpl from matplotlib import pylab as pl if colors is None: colors = [(0, 0, 0, 0.2)] lc = mpl.collections.LineCollection( np.array([((tri.x[i], tri.y[i]), (tri.x[j], tri.y[j])) for i, j in tri.edge_db]), colors=colors) ax = pl.gca() ax.add_collection(lc) pl.draw_if_interactive()
Example #3
Source File: testfuncs.py From Computable with MIT License | 5 votes |
def plot_vo(tri, colors=None): import matplotlib as mpl from matplotlib import pylab as pl if colors is None: colors = [(0, 1, 0, 0.2)] lc = mpl.collections.LineCollection(np.array( [(tri.circumcenters[i], tri.circumcenters[j]) for i in xrange(len(tri.circumcenters)) for j in tri.triangle_neighbors[i] if j != -1]), colors=colors) ax = pl.gca() ax.add_collection(lc) pl.draw_if_interactive()
Example #4
Source File: testfuncs.py From Computable with MIT License | 5 votes |
def plot_cc(tri, edgecolor=None): import matplotlib as mpl from matplotlib import pylab as pl if edgecolor is None: edgecolor = (0, 0, 1, 0.2) dxy = (np.array([(tri.x[i], tri.y[i]) for i, j, k in tri.triangle_nodes]) - tri.circumcenters) r = np.hypot(dxy[:, 0], dxy[:, 1]) ax = pl.gca() for i in xrange(len(r)): p = mpl.patches.Circle(tri.circumcenters[i], r[i], resolution=100, edgecolor=edgecolor, facecolor=(1, 1, 1, 0), linewidth=0.2) ax.add_patch(p) pl.draw_if_interactive()
Example #5
Source File: pylabtools.py From Computable with 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 #6
Source File: testfuncs.py From matplotlib-4-abaqus with MIT License | 5 votes |
def plot_dt(tri, colors=None): import matplotlib as mpl from matplotlib import pylab as pl if colors is None: colors = [(0, 0, 0, 0.2)] lc = mpl.collections.LineCollection( np.array([((tri.x[i], tri.y[i]), (tri.x[j], tri.y[j])) for i, j in tri.edge_db]), colors=colors) ax = pl.gca() ax.add_collection(lc) pl.draw_if_interactive()
Example #7
Source File: testfuncs.py From matplotlib-4-abaqus with MIT License | 5 votes |
def plot_vo(tri, colors=None): import matplotlib as mpl from matplotlib import pylab as pl if colors is None: colors = [(0, 1, 0, 0.2)] lc = mpl.collections.LineCollection(np.array( [(tri.circumcenters[i], tri.circumcenters[j]) for i in xrange(len(tri.circumcenters)) for j in tri.triangle_neighbors[i] if j != -1]), colors=colors) ax = pl.gca() ax.add_collection(lc) pl.draw_if_interactive()
Example #8
Source File: testfuncs.py From matplotlib-4-abaqus with MIT License | 5 votes |
def plot_cc(tri, edgecolor=None): import matplotlib as mpl from matplotlib import pylab as pl if edgecolor is None: edgecolor = (0, 0, 1, 0.2) dxy = (np.array([(tri.x[i], tri.y[i]) for i, j, k in tri.triangle_nodes]) - tri.circumcenters) r = np.hypot(dxy[:, 0], dxy[:, 1]) ax = pl.gca() for i in xrange(len(r)): p = mpl.patches.Circle(tri.circumcenters[i], r[i], resolution=100, edgecolor=edgecolor, facecolor=(1, 1, 1, 0), linewidth=0.2) ax.add_patch(p) pl.draw_if_interactive()
Example #9
Source File: testfuncs.py From neural-network-animation with MIT License | 5 votes |
def plot_dt(tri, colors=None): import matplotlib as mpl from matplotlib import pylab as pl if colors is None: colors = [(0, 0, 0, 0.2)] lc = mpl.collections.LineCollection( np.array([((tri.x[i], tri.y[i]), (tri.x[j], tri.y[j])) for i, j in tri.edge_db]), colors=colors) ax = pl.gca() ax.add_collection(lc) pl.draw_if_interactive()
Example #10
Source File: testfuncs.py From neural-network-animation with MIT License | 5 votes |
def plot_vo(tri, colors=None): import matplotlib as mpl from matplotlib import pylab as pl if colors is None: colors = [(0, 1, 0, 0.2)] lc = mpl.collections.LineCollection(np.array( [(tri.circumcenters[i], tri.circumcenters[j]) for i in xrange(len(tri.circumcenters)) for j in tri.triangle_neighbors[i] if j != -1]), colors=colors) ax = pl.gca() ax.add_collection(lc) pl.draw_if_interactive()
Example #11
Source File: testfuncs.py From neural-network-animation with MIT License | 5 votes |
def plot_cc(tri, edgecolor=None): import matplotlib as mpl from matplotlib import pylab as pl if edgecolor is None: edgecolor = (0, 0, 1, 0.2) dxy = (np.array([(tri.x[i], tri.y[i]) for i, j, k in tri.triangle_nodes]) - tri.circumcenters) r = np.hypot(dxy[:, 0], dxy[:, 1]) ax = pl.gca() for i in xrange(len(r)): p = mpl.patches.Circle(tri.circumcenters[i], r[i], resolution=100, edgecolor=edgecolor, facecolor=(1, 1, 1, 0), linewidth=0.2) ax.add_patch(p) pl.draw_if_interactive()
Example #12
Source File: testfuncs.py From ImageFusion with MIT License | 5 votes |
def plot_cc(tri, edgecolor=None): import matplotlib as mpl from matplotlib import pylab as pl if edgecolor is None: edgecolor = (0, 0, 1, 0.2) dxy = (np.array([(tri.x[i], tri.y[i]) for i, j, k in tri.triangle_nodes]) - tri.circumcenters) r = np.hypot(dxy[:, 0], dxy[:, 1]) ax = pl.gca() for i in xrange(len(r)): p = mpl.patches.Circle(tri.circumcenters[i], r[i], resolution=100, edgecolor=edgecolor, facecolor=(1, 1, 1, 0), linewidth=0.2) ax.add_patch(p) pl.draw_if_interactive()
Example #13
Source File: testfuncs.py From ImageFusion with MIT License | 5 votes |
def plot_dt(tri, colors=None): import matplotlib as mpl from matplotlib import pylab as pl if colors is None: colors = [(0, 0, 0, 0.2)] lc = mpl.collections.LineCollection( np.array([((tri.x[i], tri.y[i]), (tri.x[j], tri.y[j])) for i, j in tri.edge_db]), colors=colors) ax = pl.gca() ax.add_collection(lc) pl.draw_if_interactive()
Example #14
Source File: testfuncs.py From ImageFusion with MIT License | 5 votes |
def plot_vo(tri, colors=None): import matplotlib as mpl from matplotlib import pylab as pl if colors is None: colors = [(0, 1, 0, 0.2)] lc = mpl.collections.LineCollection(np.array( [(tri.circumcenters[i], tri.circumcenters[j]) for i in xrange(len(tri.circumcenters)) for j in tri.triangle_neighbors[i] if j != -1]), colors=colors) ax = pl.gca() ax.add_collection(lc) pl.draw_if_interactive()
Example #15
Source File: _timeseries.py From elasticintel with GNU General Public License v3.0 | 4 votes |
def format_dateaxis(subplot, freq, index): """ Pretty-formats the date axis (x-axis). Major and minor ticks are automatically set for the frequency of the current underlying series. As the dynamic mode is activated by default, changing the limits of the x axis will intelligently change the positions of the ticks. """ # handle index specific formatting # Note: DatetimeIndex does not use this # interface. DatetimeIndex uses matplotlib.date directly if isinstance(index, PeriodIndex): majlocator = TimeSeries_DateLocator(freq, dynamic_mode=True, minor_locator=False, plot_obj=subplot) minlocator = TimeSeries_DateLocator(freq, dynamic_mode=True, minor_locator=True, plot_obj=subplot) subplot.xaxis.set_major_locator(majlocator) subplot.xaxis.set_minor_locator(minlocator) majformatter = TimeSeries_DateFormatter(freq, dynamic_mode=True, minor_locator=False, plot_obj=subplot) minformatter = TimeSeries_DateFormatter(freq, dynamic_mode=True, minor_locator=True, plot_obj=subplot) subplot.xaxis.set_major_formatter(majformatter) subplot.xaxis.set_minor_formatter(minformatter) # x and y coord info subplot.format_coord = lambda t, y: ( "t = {0} y = {1:8f}".format(Period(ordinal=int(t), freq=freq), y)) elif isinstance(index, TimedeltaIndex): subplot.xaxis.set_major_formatter( TimeSeries_TimedeltaFormatter()) else: raise TypeError('index type not supported') pylab.draw_if_interactive()
Example #16
Source File: _timeseries.py From twitter-stock-recommendation with MIT License | 4 votes |
def format_dateaxis(subplot, freq, index): """ Pretty-formats the date axis (x-axis). Major and minor ticks are automatically set for the frequency of the current underlying series. As the dynamic mode is activated by default, changing the limits of the x axis will intelligently change the positions of the ticks. """ # handle index specific formatting # Note: DatetimeIndex does not use this # interface. DatetimeIndex uses matplotlib.date directly if isinstance(index, PeriodIndex): majlocator = TimeSeries_DateLocator(freq, dynamic_mode=True, minor_locator=False, plot_obj=subplot) minlocator = TimeSeries_DateLocator(freq, dynamic_mode=True, minor_locator=True, plot_obj=subplot) subplot.xaxis.set_major_locator(majlocator) subplot.xaxis.set_minor_locator(minlocator) majformatter = TimeSeries_DateFormatter(freq, dynamic_mode=True, minor_locator=False, plot_obj=subplot) minformatter = TimeSeries_DateFormatter(freq, dynamic_mode=True, minor_locator=True, plot_obj=subplot) subplot.xaxis.set_major_formatter(majformatter) subplot.xaxis.set_minor_formatter(minformatter) # x and y coord info subplot.format_coord = functools.partial(_format_coord, freq) elif isinstance(index, TimedeltaIndex): subplot.xaxis.set_major_formatter( TimeSeries_TimedeltaFormatter()) else: raise TypeError('index type not supported') pylab.draw_if_interactive()
Example #17
Source File: _timeseries.py From coffeegrindsize with MIT License | 4 votes |
def format_dateaxis(subplot, freq, index): """ Pretty-formats the date axis (x-axis). Major and minor ticks are automatically set for the frequency of the current underlying series. As the dynamic mode is activated by default, changing the limits of the x axis will intelligently change the positions of the ticks. """ # handle index specific formatting # Note: DatetimeIndex does not use this # interface. DatetimeIndex uses matplotlib.date directly if isinstance(index, ABCPeriodIndex): majlocator = TimeSeries_DateLocator(freq, dynamic_mode=True, minor_locator=False, plot_obj=subplot) minlocator = TimeSeries_DateLocator(freq, dynamic_mode=True, minor_locator=True, plot_obj=subplot) subplot.xaxis.set_major_locator(majlocator) subplot.xaxis.set_minor_locator(minlocator) majformatter = TimeSeries_DateFormatter(freq, dynamic_mode=True, minor_locator=False, plot_obj=subplot) minformatter = TimeSeries_DateFormatter(freq, dynamic_mode=True, minor_locator=True, plot_obj=subplot) subplot.xaxis.set_major_formatter(majformatter) subplot.xaxis.set_minor_formatter(minformatter) # x and y coord info subplot.format_coord = functools.partial(_format_coord, freq) elif isinstance(index, ABCTimedeltaIndex): subplot.xaxis.set_major_formatter( TimeSeries_TimedeltaFormatter()) else: raise TypeError('index type not supported') pylab.draw_if_interactive()
Example #18
Source File: _timeseries.py From recruit with Apache License 2.0 | 4 votes |
def format_dateaxis(subplot, freq, index): """ Pretty-formats the date axis (x-axis). Major and minor ticks are automatically set for the frequency of the current underlying series. As the dynamic mode is activated by default, changing the limits of the x axis will intelligently change the positions of the ticks. """ # handle index specific formatting # Note: DatetimeIndex does not use this # interface. DatetimeIndex uses matplotlib.date directly if isinstance(index, ABCPeriodIndex): majlocator = TimeSeries_DateLocator(freq, dynamic_mode=True, minor_locator=False, plot_obj=subplot) minlocator = TimeSeries_DateLocator(freq, dynamic_mode=True, minor_locator=True, plot_obj=subplot) subplot.xaxis.set_major_locator(majlocator) subplot.xaxis.set_minor_locator(minlocator) majformatter = TimeSeries_DateFormatter(freq, dynamic_mode=True, minor_locator=False, plot_obj=subplot) minformatter = TimeSeries_DateFormatter(freq, dynamic_mode=True, minor_locator=True, plot_obj=subplot) subplot.xaxis.set_major_formatter(majformatter) subplot.xaxis.set_minor_formatter(minformatter) # x and y coord info subplot.format_coord = functools.partial(_format_coord, freq) elif isinstance(index, ABCTimedeltaIndex): subplot.xaxis.set_major_formatter( TimeSeries_TimedeltaFormatter()) else: raise TypeError('index type not supported') pylab.draw_if_interactive()
Example #19
Source File: _timeseries.py From Splunking-Crime with GNU Affero General Public License v3.0 | 4 votes |
def format_dateaxis(subplot, freq, index): """ Pretty-formats the date axis (x-axis). Major and minor ticks are automatically set for the frequency of the current underlying series. As the dynamic mode is activated by default, changing the limits of the x axis will intelligently change the positions of the ticks. """ # handle index specific formatting # Note: DatetimeIndex does not use this # interface. DatetimeIndex uses matplotlib.date directly if isinstance(index, PeriodIndex): majlocator = TimeSeries_DateLocator(freq, dynamic_mode=True, minor_locator=False, plot_obj=subplot) minlocator = TimeSeries_DateLocator(freq, dynamic_mode=True, minor_locator=True, plot_obj=subplot) subplot.xaxis.set_major_locator(majlocator) subplot.xaxis.set_minor_locator(minlocator) majformatter = TimeSeries_DateFormatter(freq, dynamic_mode=True, minor_locator=False, plot_obj=subplot) minformatter = TimeSeries_DateFormatter(freq, dynamic_mode=True, minor_locator=True, plot_obj=subplot) subplot.xaxis.set_major_formatter(majformatter) subplot.xaxis.set_minor_formatter(minformatter) # x and y coord info subplot.format_coord = functools.partial(_format_coord, freq) elif isinstance(index, TimedeltaIndex): subplot.xaxis.set_major_formatter( TimeSeries_TimedeltaFormatter()) else: raise TypeError('index type not supported') pylab.draw_if_interactive()
Example #20
Source File: _timeseries.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 4 votes |
def format_dateaxis(subplot, freq, index): """ Pretty-formats the date axis (x-axis). Major and minor ticks are automatically set for the frequency of the current underlying series. As the dynamic mode is activated by default, changing the limits of the x axis will intelligently change the positions of the ticks. """ # handle index specific formatting # Note: DatetimeIndex does not use this # interface. DatetimeIndex uses matplotlib.date directly if isinstance(index, ABCPeriodIndex): majlocator = TimeSeries_DateLocator(freq, dynamic_mode=True, minor_locator=False, plot_obj=subplot) minlocator = TimeSeries_DateLocator(freq, dynamic_mode=True, minor_locator=True, plot_obj=subplot) subplot.xaxis.set_major_locator(majlocator) subplot.xaxis.set_minor_locator(minlocator) majformatter = TimeSeries_DateFormatter(freq, dynamic_mode=True, minor_locator=False, plot_obj=subplot) minformatter = TimeSeries_DateFormatter(freq, dynamic_mode=True, minor_locator=True, plot_obj=subplot) subplot.xaxis.set_major_formatter(majformatter) subplot.xaxis.set_minor_formatter(minformatter) # x and y coord info subplot.format_coord = functools.partial(_format_coord, freq) elif isinstance(index, ABCTimedeltaIndex): subplot.xaxis.set_major_formatter( TimeSeries_TimedeltaFormatter()) else: raise TypeError('index type not supported') pylab.draw_if_interactive()
Example #21
Source File: _timeseries.py From vnpy_crypto with MIT License | 4 votes |
def format_dateaxis(subplot, freq, index): """ Pretty-formats the date axis (x-axis). Major and minor ticks are automatically set for the frequency of the current underlying series. As the dynamic mode is activated by default, changing the limits of the x axis will intelligently change the positions of the ticks. """ # handle index specific formatting # Note: DatetimeIndex does not use this # interface. DatetimeIndex uses matplotlib.date directly if isinstance(index, PeriodIndex): majlocator = TimeSeries_DateLocator(freq, dynamic_mode=True, minor_locator=False, plot_obj=subplot) minlocator = TimeSeries_DateLocator(freq, dynamic_mode=True, minor_locator=True, plot_obj=subplot) subplot.xaxis.set_major_locator(majlocator) subplot.xaxis.set_minor_locator(minlocator) majformatter = TimeSeries_DateFormatter(freq, dynamic_mode=True, minor_locator=False, plot_obj=subplot) minformatter = TimeSeries_DateFormatter(freq, dynamic_mode=True, minor_locator=True, plot_obj=subplot) subplot.xaxis.set_major_formatter(majformatter) subplot.xaxis.set_minor_formatter(minformatter) # x and y coord info subplot.format_coord = functools.partial(_format_coord, freq) elif isinstance(index, TimedeltaIndex): subplot.xaxis.set_major_formatter( TimeSeries_TimedeltaFormatter()) else: raise TypeError('index type not supported') pylab.draw_if_interactive()