Export plot methods via RobotWithPhbands mixin

This commit is contained in:
Matteo Giantomassi 2018-01-19 21:49:11 +01:00
parent d6e5425caf
commit 1fcb2a96db
5 changed files with 34 additions and 6 deletions

View File

@ -1237,7 +1237,6 @@ class DielectricTensorGenerator(Has_Structure):
Return: |matplotlib-Figure|
"""
w_range = np.linspace(w_min, w_max, num, endpoint=True)
t = np.zeros((num,3,3))

View File

@ -3505,6 +3505,29 @@ class RobotWithPhbands(object):
"""
Mixin class for robots associated to files with |PhononBands|.
"""
def combiplot_phbands(self, **kwargs):
"""Wraps combiplot method of |PhononBandsPlotter|. kwargs passed to combiplot."""
return self.get_phbands_plotter().combiplot(**kwargs)
def gridplot_phbands(self, **kwargs):
"""Wraps gridplot method of |PhononBandsPlotter|. kwargs passed to gridplot."""
return self.get_phbands_plotter().gridplot(**kwargs)
def boxplot_phbands(self, **kwargs):
"""Wraps boxplot method of |PhononBandsPlotter|. kwargs passed to boxplot."""
return self.get_phbands_plotter().boxplot(**kwargs)
def combiboxplot_phbands(self, **kwargs):
"""Wraps combiboxplot method of |ElectronDosPlotter|. kwargs passed to combiboxplot."""
return self.get_phbands_plotter().combiboxplot(**kwargs)
#def combiplot_edos(self, **kwargs):
# """Wraps combiplot method of |ElectronDosPlotter|. kwargs passed to combiplot."""
# return self.get_edos_plotter().combiplot(**kwargs)
#
#def gridplot_edos(self, **kwargs):
# """Wraps gridplot method of |ElectronDosPlotter|. kwargs passed to gridplot."""
# return self.get_edos_plotter().gridplot(**kwargs)
def get_phbands_plotter(self, filter_abifile=None, cls=None):
"""

View File

@ -2938,7 +2938,7 @@ class ElectronDos(object):
hence what="id" plots both IDOS and DOS. (default "d").
fact: Multiplication factor for DOS/IDOS. Usually +-1 for spin DOS
exchange_xy: True to exchange x-y axis.
kwargs: Options passes to matplotlib.
kwargs: Options passed to matplotlib ``ax.plot``
Return: list of lines added to the axis.
"""
@ -3690,8 +3690,8 @@ class ElectronBands3D(Bands3D):
pass
class PhononBands3D(Bands3D):
pass
#class PhononBands3D(Bands3D):
# pass
class RobotWithEbands(object):
@ -3846,6 +3846,7 @@ class RobotWithEbands(object):
if sortby is None: rotate_ticklabels(ax, 15)
if i == 0:
ax.legend(loc="best", fontsize=fontsize, shadow=True)
#ax.legend(loc='best', fontsize=fontsize, shadow=True, fancybox=True, framealpha=0.5)
return fig

View File

@ -343,8 +343,7 @@ class QpTempList(list):
# TODO real and imag?
ax.plot(e0mesh, yt.real, linestyle,
color=cmap(itemp / self.ntemp),
#label=lbl,
label="T=%.1f K" % self.tmesh[itemp] if i == 0 else None,
label="T = %.1f K" % self.tmesh[itemp] if i == 0 else None,
**kwargs)
# Get around a bug in matplotlib

View File

@ -110,5 +110,11 @@ class EphRobotTest(AbipyTest):
assert robot.plot_a2f_convergence(show=False)
#assert robot.plot_a2ftr_convergence(show=False)
# Test wrappers provided by RobotWithPhbands
assert robot.combiplot_phbands(show=False)
assert robot.gridplot_phbands(show=False)
assert robot.boxplot_phbands(show=False)
assert robot.combiboxplot_phbands(show=False)
if self.has_nbformat():
robot.write_notebook(nbpath=self.get_tmpname(text=True))