# HG changeset patch # User Amine Sehili # Date 1570900273 -3600 # Node ID 0ea9521c80d82197da6672a3e2c4df6dd9f0885d # Parent bc963239143fa7cb4c7f7d49ce59dfc567f3531d Fix issue with plot when signal is zero diff -r bc963239143f -r 0ea9521c80d8 auditok/plotting.py --- a/auditok/plotting.py Sat Oct 12 16:23:17 2019 +0100 +++ b/auditok/plotting.py Sat Oct 12 18:11:13 2019 +0100 @@ -82,18 +82,18 @@ plot_theme = theme.get("plot", {}) plot_fc = plot_theme.get("facecolor", plot_theme.get("pfc")) for sid, samples in enumerate(y, 1): - ax = fig.add_subplot(nb_subplots, 1, sid) ax.set_facecolor(plot_fc) if scale_signal: - mean = samples.mean() std = samples.std() - samples = (samples - mean) / std - max_ = samples.max() - plt.ylim(-1.5 * max_, 1.5 * max_) - + if std > 0: + mean = samples.mean() + std = samples.std() + samples = (samples - mean) / std + max_ = samples.max() + plt.ylim(-1.5 * max_, 1.5 * max_) if amplitude_threshold is not None: - if scale_signal: + if scale_signal and std > 0: amp_th = (amplitude_threshold - mean) / std else: amp_th = amplitude_threshold