當前位置: 首頁>>代碼示例>>Python>>正文


Python pyplot.isinteractive方法代碼示例

本文整理匯總了Python中matplotlib.pyplot.isinteractive方法的典型用法代碼示例。如果您正苦於以下問題:Python pyplot.isinteractive方法的具體用法?Python pyplot.isinteractive怎麽用?Python pyplot.isinteractive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在matplotlib.pyplot的用法示例。


在下文中一共展示了pyplot.isinteractive方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: exceptionDecorator

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import isinteractive [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

示例2: redraw

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import isinteractive [as 別名]
def redraw(self):
        """
        Redraw plot. Use after custom user modifications of axes & fig objects
        """
        if plt.isinteractive():
            fig = self.kwargs['fig']
            #Redraw figure if it was previously closed prior to updating it
            if not plt.fignum_exists(fig.number):
                fig.show()
            fig.canvas.draw()
        else:
            print('redraw() is unsupported in non-interactive plotting mode!') 
開發者ID:HamsterHuey,項目名稱:easyplot,代碼行數:14,代碼來源:easyplot.py

示例3: set_mpl_interactive

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import isinteractive [as 別名]
def set_mpl_interactive():
    '''Ensure matplotlib is in interactive mode.'''
    import matplotlib.pyplot as plt

    if not plt.isinteractive():
        plt.interactive(True) 
開發者ID:spectralpython,項目名稱:spectral,代碼行數:8,代碼來源:spypylab.py

示例4: test_init

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import isinteractive [as 別名]
def test_init(self):
        ma = MatplotlibAnalyzer()
        assert plt.isinteractive()

        ta = TensorboardAnalyzer("./logs/init")

        # check to ensure path was written
        assert os.path.isdir("./logs/init")

        # check to ensure we can write data
        ta.writer.add_scalar("init_scalar", 100.0, 0)
        ta.writer.close() 
開發者ID:BindsNET,項目名稱:bindsnet,代碼行數:14,代碼來源:test_analyzers.py

示例5: turn_off_ion

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import isinteractive [as 別名]
def turn_off_ion(show_plot=True):
    ''' Turns off the Matplotlib plt interactive mode

    Context manager to temporarily disable the interactive
    Matplotlib plotting functionality.  Useful for only returning
    Figure and Axes objects

    Parameters:
        show_plot (bool):
            If True, turns off the plotting

    Example:
        >>>
        >>> with turn_off_ion(show_plot=False):
        >>>     do_some_stuff
        >>>

    '''

    plt_was_interactive = plt.isinteractive()
    if not show_plot and plt_was_interactive:
        plt.ioff()

    fignum_init = plt.get_fignums()

    yield plt

    if show_plot:
        plt.ioff()
        plt.show()
    else:
        for ii in plt.get_fignums():
            if ii not in fignum_init:
                plt.close(ii)

    # Restores original ion() status
    if plt_was_interactive and not plt.isinteractive():
        plt.ion() 
開發者ID:sdss,項目名稱:marvin,代碼行數:40,代碼來源:general.py

示例6: tensor_imshow

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import isinteractive [as 別名]
def tensor_imshow(tensor, title=None):
    inp = tensor.numpy().transpose((1, 2, 0))
    inp = np.clip(inp, 0, 1)
    plt.imshow(inp)
    if title is not None:
        plt.title(title)
    if plt.isinteractive():
        plt.ioff()
    plt.show()
# import torch
# tensor_imshow(torch.randn(3, 256, 512), 'pytorch tensor') 
開發者ID:pietrocarbo,項目名稱:deep-transfer,代碼行數:13,代碼來源:im_utils.py

示例7: add_plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import isinteractive [as 別名]
def add_plot(self, *args, **kwargs):
        """
        Add plot using supplied parameters and existing instance parameters
        
        Creates new Figure and Axes object if 'fig' and 'ax' parameters not
        supplied. Stores references to all Line2D objects plotted in 
        self.line_list. 
        Arguments
        =========
            *args : Supports format plot(y), plot(x, y), plot(x, y, 'b-'). x, y 
                    and format string are passed through for plotting
            **kwargs : Plot parameters. Refer to __init__ docstring for details
        """
        self._update(*args, **kwargs)

        # Create figure and axes if needed
        if self.kwargs['fig'] is None:
            if not self.isnewargs:
                return # Don't create fig, ax yet if no x, y data provided
            self.kwargs['fig'] = plt.figure(figsize=self.kwargs['figsize'], 
                                            dpi=self.kwargs['dpi'])
            self.kwargs['ax'] = self.kwargs['fig'].gca()
            self.kwargs['fig'].add_axes(self.kwargs['ax'])

        ax, fig = self.kwargs['ax'], self.kwargs['fig']
        
        ax.ticklabel_format(useOffset=False) # Prevent offset notation in plots

        # Apply axes functions if present in kwargs
        for kwarg in self.kwargs:
            if kwarg in self._ax_funcs:
                # eg: f = getattr(ax,'set_title'); f('new title')
                func = getattr(ax, self._ax_funcs[kwarg])
                func(self.kwargs[kwarg])
        
        # Add plot only if new args passed to this instance
        if self.isnewargs:
            # Create updated name, value dict to pass to plot method
            plot_kwargs = {kwarg: self.kwargs[kwarg] for kwarg 
                                in self._plot_kwargs if kwarg in self.kwargs}
            
            line, = ax.plot(*self.args, **plot_kwargs)
            self.line_list.append(line)            
          
        # Display legend if required
        if self.kwargs['showlegend']:
            legend_kwargs = {kwarg: self.kwargs[kwarg] for kwarg 
                                in self._legend_kwargs if kwarg in self.kwargs}
            leg = ax.legend(**legend_kwargs)
            if leg is not None:
                leg.draggable(state=True)
        
        if 'fontsize' in self.kwargs:
            self.set_fontsize(self.kwargs['fontsize'])
            
        self._delete_uniqueparams() # Clear unique parameters from kwargs list
        
        if plt.isinteractive(): # Only redraw canvas in interactive mode
            self.redraw() 
開發者ID:HamsterHuey,項目名稱:easyplot,代碼行數:61,代碼來源:easyplot.py

示例8: __init__

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import isinteractive [as 別名]
def __init__(self, *args, **kwargs):
        import matplotlib as mpl
        import matplotlib.pyplot as plt
        from collections import deque
        kwargs['gui'] = True

        super(tqdm_gui, self).__init__(*args, **kwargs)

        # Initialize the GUI display
        if self.disable or not kwargs['gui']:
            return

        warn('GUI is experimental/alpha', TqdmExperimentalWarning)
        self.mpl = mpl
        self.plt = plt
        self.sp = None

        # Remember if external environment uses toolbars
        self.toolbar = self.mpl.rcParams['toolbar']
        self.mpl.rcParams['toolbar'] = 'None'

        self.mininterval = max(self.mininterval, 0.5)
        self.fig, ax = plt.subplots(figsize=(9, 2.2))
        # self.fig.subplots_adjust(bottom=0.2)
        if self.total:
            self.xdata = []
            self.ydata = []
            self.zdata = []
        else:
            self.xdata = deque([])
            self.ydata = deque([])
            self.zdata = deque([])
        self.line1, = ax.plot(self.xdata, self.ydata, color='b')
        self.line2, = ax.plot(self.xdata, self.zdata, color='k')
        ax.set_ylim(0, 0.001)
        if self.total:
            ax.set_xlim(0, 100)
            ax.set_xlabel('percent')
            self.fig.legend((self.line1, self.line2), ('cur', 'est'),
                            loc='center right')
            # progressbar
            self.hspan = plt.axhspan(0, 0.001,
                                     xmin=0, xmax=0, color='g')
        else:
            # ax.set_xlim(-60, 0)
            ax.set_xlim(0, 60)
            ax.invert_xaxis()
            ax.set_xlabel('seconds')
            ax.legend(('cur', 'est'), loc='lower left')
        ax.grid()
        # ax.set_xlabel('seconds')
        ax.set_ylabel((self.unit if self.unit else 'it') + '/s')
        if self.unit_scale:
            plt.ticklabel_format(style='sci', axis='y',
                                 scilimits=(0, 0))
            ax.yaxis.get_offset_text().set_x(-0.15)

        # Remember if external environment is interactive
        self.wasion = plt.isinteractive()
        plt.ion()
        self.ax = ax 
開發者ID:Tautulli,項目名稱:Tautulli,代碼行數:63,代碼來源:_tqdm_gui.py


注:本文中的matplotlib.pyplot.isinteractive方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。