Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change dispersion plot ylimit handling #107

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions tp/plot/phonons.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,6 @@ def add_dispersion(ax, data, sdata=None, bandmin=None, bandmax=None, main=True,
if main:
if round(np.amin(f), 1) == 0:
ax.set_ylim(bottom=0)
else:
ax.set_ylim(bottom=np.amin(f))
if sdata is None: sdata = data
formatting(ax, sdata, 'frequency', **xmarkkwargs)

Expand Down Expand Up @@ -833,8 +831,6 @@ def add_projected_dispersion(ax, data, pdata, quantity, bandmin=None,
if main:
if round(np.amin(f), 1) == 0:
ax.set_ylim(bottom=0)
else:
ax.set_ylim(bottom=np.amin(f))
formatting(ax, pdata, 'frequency', **xmarkkwargs)

return cbar
Expand Down Expand Up @@ -1254,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 @@ -1301,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
Loading