Skip to content

Commit

Permalink
Update ylim for add_wideband plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
dgaines2 committed Dec 20, 2024
1 parent 6058b89 commit 6b218d1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tp/plot/phonons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6b218d1

Please sign in to comment.