本文整理汇总了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()
示例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()
示例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)
示例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()