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


Python matplotlib.show方法代碼示例

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


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

示例1: pairwise_time_distribution

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import show [as 別名]
def pairwise_time_distribution(self, event_order, time_col=None, index_col=None,
                                   event_col=None, bins=100, limit=180, topk=3):
        self._init_cols(locals())
        if 'next_event' not in self._obj.columns:
            self._get_shift(index_col, event_col)
        self._obj['time_diff'] = (self._obj['next_timestamp'] - self._obj[
            time_col or self.retention_config['event_time_col']]).dt.total_seconds()
        f_cur = self._obj[self._event_col()] == event_order[0]
        f_next = self._obj['next_event'] == event_order[1]
        s_next = self._obj[f_cur & f_next].copy()
        s_cur = self._obj[f_cur & (~f_next)].copy()

        s_cur.time_diff[s_cur.time_diff < limit].hist(alpha=0.5, log=True,
                                                      bins=bins, label='Others {:.2f}'.format(
                                                          (s_cur.time_diff < limit).sum() / f_cur.sum()
                                                      ))
        s_next.time_diff[s_next.time_diff < limit].hist(alpha=0.7, log=True,
                                                        bins=bins,
                                                        label='Selected event order {:.2f}'.format(
                                                            (s_next.time_diff < limit).sum() / f_cur.sum()
                                                        ))
        plot.sns.mpl.pyplot.legend()
        plot.sns.mpl.pyplot.show()
        (s_cur.next_event.value_counts() / f_cur.sum()).iloc[:topk].plot.bar() 
開發者ID:retentioneering,項目名稱:retentioneering-tools,代碼行數:26,代碼來源:utils.py

示例2: draw

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import show [as 別名]
def draw(self):
        """
        Draw a network graph of the employee relationship.
        """
        if self.graph is not None:
            nx.draw_networkx(self.graph)
            plt.show() 
開發者ID:gcallah,項目名稱:indras_net,代碼行數:9,代碼來源:emp_model.py

示例3: calculate_delays

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import show [as 別名]
def calculate_delays(self, plotting=True, time_col=None, index_col=None, event_col=None, bins=15, **kwargs):
        """
        Displays the logarithm of delay between ``time_col`` with the next value in nanoseconds as a histogram.

        Parameters
        --------
        plotting: bool, optional
            If ``True``, then histogram is plotted as a graph. Default: ``True``
        time_col: str, optional
            Name of custom time column for more information refer to ``init_config``. For instance, if in config you have defined ``event_time_col`` as ``server_timestamp``, but want to use function over ``user_timestamp``. By default the column defined in ``init_config`` will be used as ``time_col``.
        index_col: str, optional
            Name of custom index column, for more information refer to ``init_config``. For instance, if in config you have defined ``index_col`` as ``user_id``, but want to use function over sessions. By default the column defined in ``init_config`` will be used as ``index_col``.
        event_col: str, optional
            Name of custom event column, for more information refer to ``init_config``. For instance, you may want to aggregate some events or rename and use it as new event column. By default the column defined in ``init_config`` will be used as ``event_col``.
        bins: int, optional
            Number of bins for visualisation. Default: ``50``

        Returns
        -------
        Delays in seconds for each ``time_col``. Index is preserved as in original dataset.

        Return type
        -------
        List
        """
        self._init_cols(locals())
        self._get_shift(self._index_col(), self._event_col())

        delays = np.log((self._obj['next_timestamp'] - self._obj[self._event_time_col()]) // pd.Timedelta('1s'))

        if plotting:
            fig, ax = plot.sns.mpl.pyplot.subplots(figsize=kwargs.get('figsize', (15, 7)))  # control figsize for proper display on large bin numbers
            _, bins, _ = plt.hist(delays[~np.isnan(delays) & ~np.isinf(delays)], bins=bins, log=True)
            if not kwargs.get('logvals', False):  # test & compare with logarithmic and normal
                plt.xticks(bins, np.around(np.exp(bins), 1))
            plt.show()

        return np.exp(delays) 
開發者ID:retentioneering,項目名稱:retentioneering-tools,代碼行數:40,代碼來源:utils.py

示例4: spect

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import show [as 別名]
def spect(tr,fmin = 0.1,fmax = None,wlen=10,title=None):
    import matplotlib as plt
    if fmax is None:
        fmax = tr.stats.sampling_rate/2
    fig = plt.figure()
    ax1 = fig.add_axes([0.1, 0.75, 0.7, 0.2]) #[left bottom width height]
    ax2 = fig.add_axes([0.1, 0.1, 0.7, 0.60], sharex=ax1)
    ax3 = fig.add_axes([0.83, 0.1, 0.03, 0.6])

    #make time vector
    t = np.arange(tr.stats.npts) / tr.stats.sampling_rate

    #plot waveform (top subfigure)    
    ax1.plot(t, tr.data, 'k')

    #plot spectrogram (bottom subfigure)
    tr2 = tr.copy()
    fig = tr2.spectrogram(per_lap=0.9,wlen=wlen,show=False, axes=ax2)
    mappable = ax2.images[0]
    plt.colorbar(mappable=mappable, cax=ax3)
    ax2.set_ylim(fmin, fmax)
    ax2.set_xlabel('Time [s]')
    ax2.set_ylabel('Frequency [Hz]')
    if title:
        plt.suptitle(title)
    else:
        plt.suptitle('{}.{}.{} {}'.format(tr.stats.network,tr.stats.station,
                  tr.stats.channel,tr.stats.starttime))
    plt.show() 
開發者ID:mdenolle,項目名稱:NoisePy,代碼行數:31,代碼來源:noise_module.py


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