diff --git a/tp/plot/phonons.py b/tp/plot/phonons.py index 36e2e74..c0b17b3 100644 --- a/tp/plot/phonons.py +++ b/tp/plot/phonons.py @@ -1250,8 +1250,12 @@ def add_wideband(ax, kdata, pdata, temperature=300, bandmin=None, bandmax=None, cinterp = interp1d(xi, c2, kind='cubic', axis=0) c2 = np.abs(cinterp(x2)) - fmax = np.amax(np.add(f, c2)) if ymax is None else ymax - fmin = np.amin(np.subtract(f, c2)) if ymin is None else ymin + fmax = np.amax(np.add(f, c2)) + fmin = np.amin(np.subtract(f, c2)) + margin = (fmax - fmin) * 0.05 + fmax = fmax + margin if ymax is None else ymax + fmin = fmin - margin if ymin is None else ymin + c2 = np.where(c2==0, np.nanmin(c2[np.nonzero(c2)]), c2) f2 = np.linspace(fmin, fmax, 2500) @@ -1297,9 +1301,9 @@ def add_wideband(ax, kdata, pdata, temperature=300, bandmin=None, bandmax=None, if main: if round(np.amin(f), 1) == 0: - ax.set_ylim(bottom=0) + ax.set_ylim(bottom=0, top=fmax) else: - ax.set_ylim(bottom=fmin) + ax.set_ylim(bottom=fmin, top=fmax) formatting(ax, pdata, 'frequency', **xmarkkwargs) return