Skip to content

Commit

Permalink
Merge pull request #98 from SMTG-Bham/bug-fix
Browse files Browse the repository at this point in the history
fix multiphon error for different sized x axes
  • Loading branch information
kbspooner committed Apr 17, 2024
2 parents 20bee4e + 004b509 commit 0392def
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/test_plot/test_phonons.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_bandmin(self):
self.ax.set_xlabel.assert_called_once()
self.ax.set_ylabel.assert_called_once()
self.ax.set_xlim.assert_called_once_with(0, 1)
self.ax.set_ylim.assert_not_called()
self.ax.set_ylim.assert_called_once_with(bottom=0)

def test_bandmax(self):
self.ax.spines['bottom'].get_linewidth().return_value = 1
Expand Down
14 changes: 9 additions & 5 deletions tp/plot/phonons.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,15 @@ def add_multi(ax, data, bandmin=None, bandmax=None, main=True, label=None,
else:
bandmax = np.amin([len(data[0]['frequency'][0]), bandmax])

f = [d['frequency'] for d in data]
f = np.array(f)[:,:,bandmin:bandmax]

if round(np.amin(f), 1) == 0:
ax.set_ylim(bottom=0)
if bandmin < 3:
f = [d['frequency'] for d in data]
noim = True
for ff in f:
ff = np.array(ff)[:,bandmin:bandmax]
if round(np.amin(ff), 1) < 0:
noim = False
if noim == True:
ax.set_ylim(bottom=0)
formatting(ax, data[0], 'frequency', **xmarkkwargs)

return
Expand Down

0 comments on commit 0392def

Please sign in to comment.