Plotting¶
Plotting in Euphonic is contained in a separate euphonic.plot module,
and all plotting functions return a matplotlib.figure.Figure, which can
be tweaked, then viewed with matplotlib.figure.Figure.show()
Plotting Dispersion¶
Phonon dispersion can be plotted straight from the q-points/frequencies in a
QpointPhononModes object with
euphonic.plot.plot_dispersion(). Extra arguments get passed to
plot_1d, for adding axis labels
etc.:
from euphonic import QpointPhononModes
from euphonic.plot import plot_dispersion
phonons = QpointPhononModes.from_castep('quartz.phonon')
fig = plot_dispersion(phonons, y_label='Energy (meV)')
fig.show()
Docstring¶
-
plot_dispersion(phonons, btol=10.0, *args, **kwargs)¶ Creates a Matplotlib figure displaying phonon dispersion from a QpointPhononModes object
Parameters: - phonons (QpointPhononModes) – Containing the q-points/frequencies to plot
- btol (float, optional) – Determines the limit for plotting sections of reciprocal space on different subplots, as a fraction of the median distance between q-points
- *args – Get passed to plot_1d
- **kwargs – Get passed to plot_1d
1D Plots¶
1D spectra are plotted with euphonic.plot.plot_1d(). Multiple 1D
spectra can be plotted on the same axis by passing a list:
from euphonic import Spectrum1D
from euphonic.plot import plot_1d
dos = Spectrum1D.from_json_file('dos.json')
dos_broaden = Spectrum1D.from_json_file('dos_broaden.json')
fig = plot_1d([dos, dos_broaden], x_label='Energy (meV)', y_min=0,
labels=['dos', 'broadened dos'])
fig.show()
Docstring¶
-
plot_1d(spectra, title='', x_label='', y_label='', y_min=None, labels=[], btol=None, _split_line_x_idx=array([], dtype=int32), **line_kwargs)¶ Creates a Matplotlib figure for a Spectrum1D object, or multiple Spectrum1D objects to be plotted on the same axes
Parameters: - spectra (Spectrum1D or list of Spectrum1D) – Containing the 1D data to plot. Note only the x_tick_labels in the first spectrum in the list will be used
- title (string, optional) – Plot title
- x_label (string, optional) – X-axis label
- y_label (string, optional) – Y-axis label
- y_min (float, optional) – Minimum value on the y-axis. Can be useful to set y-axis minimum to 0 for energy, for example.
- labels (list of str, optional) – Legend labels for spectra, in the same order as spectra
- btol (float, optional) – If there are large gaps on the x-axis (e.g sections of reciprocal space) data can be plotted in sections on different subplots. btol is the limit for plotting on different subplots, as a fraction of the median distance between points. Note that if multiple Spectrum1D objects have been provided, the axes will only be determined by the first spectrum in the list
- **line_kwargs (matplotlib.line.Line2D properties, optional) – Used in the axes.plot command to specify properties like linewidth, linestyle
Returns: fig – The figure
Return type: matplotlib.figure.Figure
2D Plots¶
2D spectra are plotted with euphonic.plot.plot_2d():
from euphonic import Spectrum2D
from euphonic.plot import plot_2d
sqw = Spectrum2D.from_json_file('sqw.json')
fig, ims = plot_2d(sqw, ratio=1.0)
fig.show()
Docstring¶
-
plot_2d(spectrum, vmin=None, vmax=None, ratio=None, x_width=0, y_width=0, cmap='viridis', title='', x_label='', y_label='')¶ Creates a Matplotlib figure for a Spectrum2D object
Parameters: - spectrum (Spectrum2D) – Containing the 2D data to plot
- vmin (float, optional) – Minimum of data range for colormap. See Matplotlib imshow docs Default: None
- vmax (float, optional) – Maximum of data range for colormap. See Matplotlib imshow docs Default: None
- ratio (float, optional) – Ratio of the size of the y and x axes. e.g. if ratio is 2, the y-axis will be twice as long as the x-axis Default: None
- cmap (string, optional) – Which colormap to use, see Matplotlib docs
- title (string, optional) – The figure title. Default: ‘’
- x_label (string, optional) – X-axis label
- y_label (string, optional) – Y-axis label
Returns: - fig (matplotlib.figure.Figure) – The figure
- ims ((n_qpts,) ‘matplotlib.image.AxesImage’ ndarray) – A Numpy.ndarray of AxesImage objects, one for each x-bin, for easier access to some attributes/functions