Python matplotlib.show() Examples
The following are 4 code examples for showing how to use matplotlib.show(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
matplotlib
, or try the search function
.
Example 1
Project: retentioneering-tools Author: retentioneering File: utils.py License: Mozilla Public License 2.0 | 6 votes |
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()
Example 2
Project: indras_net Author: gcallah File: emp_model.py License: GNU General Public License v3.0 | 5 votes |
def draw(self): """ Draw a network graph of the employee relationship. """ if self.graph is not None: nx.draw_networkx(self.graph) plt.show()
Example 3
Project: retentioneering-tools Author: retentioneering File: utils.py License: Mozilla Public License 2.0 | 5 votes |
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)
Example 4
Project: NoisePy Author: mdenolle File: noise_module.py License: MIT License | 5 votes |
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()