# pymatgen.phonon.plotter module¶

class PhononBSPlotter(bs)[source]

Bases: object

Class to plot or get data to facilitate the plot of band structure objects.

Parameters: bs – A BandStructureSymmLine object.
bs_plot_data()[source]

Get the data nicely formatted for a plot

Returns: ticks: A dict with the ‘distances’ at which there is a qpoint (the x axis) and the labels (None if no label) frequencies: A list (one element for each branch) of frequencies for each qpoint: [branch][qpoint][mode]. The data is stored by branch to facilitate the plotting lattice: The reciprocal lattice. A dict of the following format
get_plot(ylim=None)[source]

Get a matplotlib object for the bandstructure plot.

Parameters: ylim – Specify the y-axis (frequency) limits; by default None let the code choose.
get_ticks()[source]

Get all ticks and labels for a band structure plot.

Returns: a list of distance at which ticks should be set and ‘label’: a list of label for each of those ticks. A dict with ‘distance’
plot_brillouin()[source]

plot the Brillouin zone

plot_compare(other_plotter)[source]

plot two band structure for comparison. One is in red the other in blue. The two band structures need to be defined on the same symmetry lines! and the distance between symmetry lines is the one of the band structure used to build the PhononBSPlotter

Parameters: PhononBSPlotter object defined along the same symmetry lines (another) – a matplotlib object with both band structures
save_plot(filename, img_format='eps', ylim=None)[source]

Save matplotlib plot to a file.

Parameters: filename – Filename to write to. img_format – Image format to use. Defaults to EPS. ylim – Specifies the y-axis limits.
show(ylim=None)[source]

Show the plot using matplotlib.

Parameters: ylim – Specify the y-axis (frequency) limits; by default None let the code choose.
class PhononDosPlotter(stack=False, sigma=None)[source]

Bases: object

Class for plotting phonon DOSs. Note that the interface is extremely flexible given that there are many different ways in which people want to view DOS. The typical usage is:

# Initializes plotter with some optional args. Defaults are usually
# fine,
plotter = PhononDosPlotter()

# Adds a DOS with a label.

# Alternatively, you can add a dict of DOSs. This is the typical
# form returned by CompletePhononDos.get_element_dos().

Parameters: stack – Whether to plot the DOS as a stacked area graph key_sort_func – function used to sort the dos_dict keys. sigma – A float specifying a standard deviation for Gaussian smearing the DOS for nicer looking plots. Defaults to None for no smearing.
add_dos(label, dos)[source]

Parameters: label – label for the DOS. Must be unique. dos – PhononDos object
add_dos_dict(dos_dict, key_sort_func=None)[source]

Add a dictionary of doses, with an optional sorting function for the keys.

Parameters: dos_dict – dict of {label: Dos} key_sort_func – function used to sort the dos_dict keys.
get_dos_dict()[source]

Returns the added doses as a json-serializable dict. Note that if you have specified smearing for the DOS plot, the densities returned will be the smeared densities, not the original densities.

Returns: {‘frequencies’:.., ‘densities’: ...}} Dict of dos data. Generally of the form, {label
get_plot(xlim=None, ylim=None)[source]

Get a matplotlib plot showing the DOS.

Parameters: xlim – Specifies the x-axis limits. Set to None for automatic determination. ylim – Specifies the y-axis limits.
save_plot(filename, img_format='eps', xlim=None, ylim=None)[source]

Save matplotlib plot to a file.

Parameters: filename – Filename to write to. img_format – Image format to use. Defaults to EPS. xlim – Specifies the x-axis limits. Set to None for automatic determination. ylim – Specifies the y-axis limits.
show(xlim=None, ylim=None)[source]

Show the plot using matplotlib.

Parameters: xlim – Specifies the x-axis limits. Set to None for automatic determination. ylim – Specifies the y-axis limits.