Skip to content

Commit

Permalink
add ability to override phonon and wideband plot axis limits at the c…
Browse files Browse the repository at this point in the history
…ommand line
  • Loading branch information
Kieran B. Spooner committed Jun 24, 2024
1 parent 7e0a45a commit 60bd5ea
Showing 1 changed file with 47 additions and 3 deletions.
50 changes: 47 additions & 3 deletions tp/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1549,13 +1549,15 @@ def kappa_target(transport_file, zt, direction, interpolate, kind, colour,
@fill_options

@legend_function(toggle=False)
@axes_limit_function()
@plot_io_function('tp-phonons')

def converge_phonons(band_yaml, bandmin, bandmax, colour, alpha, linestyle,
marker, xmarkcolour, xmarklinestyle, dos, poscar, atoms,
projected, sigma, total, total_label, total_colour,
doscolour, fill, fillalpha, line, label, legend_title,
location, style, large, save, show, extension, output):
location, xmin, xmax, ymin, ymax, style, large, save, show,
extension, output):
"""Plots and overlays phonon dispersions.
Can have optional DoS on the side.
Expand Down Expand Up @@ -1605,6 +1607,30 @@ def converge_phonons(band_yaml, bandmin, bandmax, colour, alpha, linestyle,
totalcolour=total_colour, fill=fill,
fillalpha=fillalpha, line=line, invert=True)
dosax.set_ylim(ax.get_ylim())

if xmin is not None:
if xmax is not None:
ax.set_xlim(xmin, xmax)
else:
ax.set_xlim(left=xmin)
elif xmax is not None:
ax.set_xlim(right=xmax)

if ymin is not None:
if ymax is not None:
ax.set_ylim(ymin, ymax)
if dos is not None:
dosax.set_ylim(ymin, ymax)
else:
ax.set_ylim(bottom=ymin)
if dos is not None:
dosax.set_ylim(bottom=ymin)
elif ymax is not None:
ax.set_ylim(top=ymax)
if dos is not None:
dosax.set_ylim(top=ymax)

if dos is not None:
tp.plot.utilities.set_locators(dosax, dos=True)

if label != [None] or dos is not None:
Expand Down Expand Up @@ -2198,11 +2224,13 @@ def waterfall(kappa_hdf5, y, x, projected, direction, temperature, colour, alpha
default=5,
show_default=True)

@axes_limit_function()
@plot_io_function('tp-wideband')
@verbose_option

def wideband(band_yaml, kappa_hdf5, temperature, poscar, colour, smoothing, style,
large, save, show, extension, output, verbose):
def wideband(band_yaml, kappa_hdf5, temperature, poscar, colour, smoothing,
style, xmin, xmax, ymin, ymax, large, save, show, extension,
output, verbose):
"""Plots a broadened phonon dispersion."""

axes = tp.axes.large if large else tp.axes.small
Expand All @@ -2220,6 +2248,22 @@ def wideband(band_yaml, kappa_hdf5, temperature, poscar, colour, smoothing, styl
poscar=poscar, smoothing=smoothing,
colour=colour, verbose=verbose)

if xmin is not None:
if xmax is not None:
ax.set_xlim(xmin, xmax)
else:
ax.set_xlim(left=xmin)
elif xmax is not None:
ax.set_xlim(right=xmax)

if ymin is not None:
if ymax is not None:
ax.set_ylim(ymin, ymax)
else:
ax.set_ylim(bottom=ymin)
elif ymax is not None:
ax.set_ylim(top=ymax)

if save:
for ext in extension:
fig.savefig('{}.{}'.format(output, ext))
Expand Down

0 comments on commit 60bd5ea

Please sign in to comment.