sumo.plotting package

Module contents

Subpackage providing helper functions for generating publication ready plots.

sumo.plotting.colorline(x, y, weights, color1='#FF0000', color2='#00FF00', color3='#0000FF', colorspace='lab', linestyles='solid', linewidth=2.5)[source]

Get a RGB coloured line for plotting.

Parameters:
  • x (list) – x-axis data.

  • y (list) – y-axis data (can be multidimensional array).

  • weights (list) – The weights of the color1, color2, and color3 channels. Given as an array with the shape (n, 3), where n is the same length as the x and y data.

  • color1 (str) – A color specified in any way supported by matplotlib.

  • color2 (str) – A color specified in any way supported by matplotlib.

  • color3 (str) – A color specified in any way supported by matplotlib.

  • colorspace (str) – The colorspace in which to perform the interpolation. The allowed values are rgb, hsv, lab, luvlc, lablch, and xyz.

  • linestyles (str, optional) – Linestyle for plot. Options are "solid" or "dotted".

sumo.plotting.curry_power_tick(times_sign='\\times')[source]
sumo.plotting.draw_themed_line(y, ax, orientation='horizontal', **kwargs)[source]

Draw a horizontal line using the theme settings

Parameters:
  • y (float) – Position of line in data coordinates

  • ax (Axes) – Matplotlib Axes on which line is drawn

  • orientation (str, optional) – Orientation of line. Options are "horizontal" or "vertical".

  • **kwargs – Additional keyword arguments passed to ax.axhline or ax.axvline, which can be used to override the theme settings.

sumo.plotting.get_interpolated_colors(color1, color2, color3, weights, colorspace='lab')[source]

Interpolate colors at a number of points within a colorspace.

Parameters:
  • color1 (str) – A color specified in any way supported by matplotlib.

  • color2 (str) – A color specified in any way supported by matplotlib.

  • color3 (str) – A color specified in any way supported by matplotlib.

  • weights (list) – A list of weights with the shape (n, 3). Where the 3 values of the last axis give the amount of color1, color2, and color3.

  • colorspace (str) – The colorspace in which to perform the interpolation. The allowed values are rgb, hsv, lab, luvlc, lablch, and xyz.

Returns:

A list of colors, specified in the rgb format as a (n, 3) array.

sumo.plotting.power_tick(val, pos, times_sign='\\times')[source]

Custom power ticker function.

sumo.plotting.pretty_plot(width=None, height=None, plt=None, dpi=None)[source]

Get a matplotlib.pyplot object with publication ready defaults.

Parameters:
  • width (float, optional) – The width of the plot.

  • height (float, optional) – The height of the plot.

  • plt (matplotlib.pyplot, optional) – A matplotlib.pyplot object to use for plotting.

  • dpi (int, optional) – The dots-per-inch (pixel density) for the plot.

Returns:

A matplotlib.pyplot object with publication ready defaults set.

Return type:

matplotlib.pyplot

sumo.plotting.pretty_subplot(nrows, ncols, width=None, height=None, sharex=True, sharey=True, dpi=None, plt=None, gridspec_kw=None)[source]

Get a matplotlib.pyplot subplot object with pretty defaults.

Parameters:
  • nrows (int) – The number of rows in the subplot.

  • ncols (int) – The number of columns in the subplot.

  • width (float, optional) – The width of the plot.

  • height (float, optional) – The height of the plot.

  • sharex (bool, optional) – All subplots share the same x-axis. Defaults to True.

  • sharey (bool, optional) – All subplots share the same y-axis. Defaults to True.

  • dpi (int, optional) – The dots-per-inch (pixel density) for the plot.

  • plt (matplotlib.pyplot, optional) – A matplotlib.pyplot object to use for plotting.

  • gridspec_kw (dict, optional) – Gridspec parameters. Please see: matplotlib.pyplot.subplot for more information. Defaults to None.

Returns:

A matplotlib.pyplot subplot object with publication ready defaults set.

Return type:

matplotlib.pyplot

sumo.plotting.styled_plot(*style_sheets)[source]

Return a decorator that will apply matplotlib style sheets to a plot.

style_sheets is a base set of styles, which will be ignored if no_base_style is set in the decorated function arguments.

The style will further be overwritten by any styles in the style optional argument of the decorated function.

Parameters:

style_sheets (list, str, or dict) – Any matplotlib supported definition of a style sheet. Can be a list of style of style sheets.

Submodules

sumo.plotting.bs_plotter module

This module provides a class for plotting electronic band structure diagrams.

class sumo.plotting.bs_plotter.SBSPlotter(bs)[source]

Bases: BSPlotter

Class for plotting electronic band structures.

This class is similar to the pymatgen pymatgen.electronic_structure.plotter.BSPlotter class but overrides some methods to generate prettier plots.

Additional functionality, such as projected band structure plots are available.

Parameters:

bs (BandStructureSymmLine) – The band structure.

get_plot(zero_to_efermi=True, zero_line=False, zero_energy=None, ymin=-6.0, ymax=6.0, width=None, height=None, vbm_cbm_marker=False, ylabel='Energy (eV)', dpi=None, plt=None, plot_dos_legend=True, dos_plotter=None, dos_options=None, dos_label=None, dos_aspect=3, aspect=None, spin=None, fonts=None, style=None, no_base_style=False, title=None)[source]

Get a matplotlib.pyplot object of the band structure.

If the system is spin polarised, and no spin has been specified, orange lines are spin up, dashed blue lines are spin down. For metals, all bands are coloured blue. For semiconductors, blue lines indicate valence bands and orange lines indicates conduction bands.

Parameters:
  • zero_to_efermi (bool) – Shift the plot such that the Fermi energy of the band structure data is plotted at 0 eV. Note that this “efermi” is for the benefit of Pymatgen and may not reflect the actual Fermi level; in Sumo it has usually already been shifted to the VBM.

  • zero_line (bool, optional) – Draw a horizontal line at zero

  • zero_energy (float, optional) – Zero energy reference. (If unset, defaults to VBM or Fermi Energy as appropriate.)

  • ymin (float, optional) – The minimum energy on the y-axis.

  • ymax (float, optional) – The maximum energy on the y-axis.

  • width (float, optional) – The width of the plot.

  • height (float, optional) – The height of the plot.

  • vbm_cbm_marker (bool, optional) – Plot markers to indicate the VBM and CBM locations.

  • ylabel (str, optional) – y-axis (i.e. energy) label/units

  • dpi (int, optional) – The dots-per-inch (pixel density) for the image.

  • plt (matplotlib.pyplot, optional) – A matplotlib.pyplot object to use for plotting.

  • dos_plotter (SDOSPlotter, optional) – Plot the density of states alongside the band structure. This should be a SDOSPlotter object initialised with the data to plot.

  • dos_options (dict, optional) –

    The options for density of states plotting. This should be formatted as a dict containing any of the following keys:

    ”yscale” (float)

    Scaling factor for the y-axis.

    ”xmin” (float)

    The minimum energy to mask the energy and density of states data (reduces plotting load).

    ”xmax” (float)

    The maximum energy to mask the energy and density of states data (reduces plotting load).

    ”colours” (dict)

    Use custom colours for specific element and orbital combinations. Specified as a dict of dict of the colours. For example:

    {
        'Sn': {'s': 'r', 'p': 'b'},
        'O': {'s': '#000000'}
    }
    

    The colour can be a hex code, series of rgb value, or any other format supported by matplotlib.

    ”plot_total” (bool)

    Plot the total density of states. Defaults to True.

    ”legend_cutoff” (float)

    The cut-off (in % of the maximum density of states within the plotting range) for an elemental orbital to be labelled in the legend. This prevents the legend from containing labels for orbitals that have very little contribution in the plotting range.

    ”subplot” (bool)

    Plot the density of states for each element on separate subplots. Defaults to False.

  • dos_label (str, optional) – DOS axis label/units

  • dos_aspect (float, optional) – Aspect ratio for the band structure and density of states subplot. For example, dos_aspect = 3, results in a ratio of 3:1, for the band structure:dos plots.

  • plot_dos_legend (bool) – Whether to plot the dos legend.

  • aspect (float, optional) – The aspect ratio of the band structure plot. By default the dimensions of the figure size are used to determine the aspect ratio. Set to 1 to force the plot to be square.

  • spin (Spin, optional) – Plot a spin-polarised band structure, “up” or “1” for spin up only, “down” or “-1” for spin down only. Defaults to None.

  • fonts (list, optional) – Fonts to use in the plot. Can be a a single font, specified as a str, or several fonts, specified as a list of str.

  • style (list, str, or dict) – Any matplotlib style specifications, to be composed on top of Sumo base style.

  • no_base_style (bool, optional) – Prevent use of sumo base style. This can make alternative styles behave more predictably.

Returns:

The electronic band structure plot.

Return type:

matplotlib.pyplot

get_projected_plot(selection, mode='rgb', normalise='all', interpolate_factor=4, color1='#FF0000', color2='#0000FF', color3='#00FF00', colorspace='lab', circle_size=150, projection_cutoff=0.001, zero_energy=None, zero_to_efermi=True, zero_line=False, ymin=-6.0, ymax=6.0, width=None, height=None, vbm_cbm_marker=False, ylabel='Energy (eV)', dpi=400, plt=None, dos_plotter=None, dos_options=None, dos_label=None, plot_dos_legend=True, dos_aspect=3, aspect=None, fonts=None, style=None, no_base_style=False, spin=None, title=None)[source]

Get a matplotlib.pyplot of the projected band structure.

If the system is spin polarised, no spin has been specified and mode = 'rgb' spin up and spin down bands are differentiated by solid and dashed lines, respectively. For the other modes, spin up and spin down are plotted separately.

Parameters:
  • selection (list) –

    A list of tuple or string identifying which elements and orbitals to project on to the band structure. These can be specified by both element and orbital, for example, the following will project the Bi s, p and S p orbitals:

    [('Bi', 's'), ('Bi', 'p'), ('S', 'p')]
    

    If just the element is specified then all the orbitals of that element are combined. For example, to sum all the S orbitals:

    [('Bi', 's'), ('Bi', 'p'), 'S']
    

    You can also choose to sum particular orbitals by supplying a tuple of orbitals. For example, to sum the S s, p, and d orbitals into a single projection:

    [('Bi', 's'), ('Bi', 'p'), ('S', ('s', 'p', 'd'))]
    

    If mode = 'rgb', a maximum of 3 orbital/element combinations can be plotted simultaneously (one for red, green and blue), otherwise an unlimited number of elements/orbitals can be selected.

  • mode (str, optional) –

    Type of projected band structure to plot. Options are:

    ”rgb”

    The band structure line color depends on the character of the band. Each element/orbital contributes either red, green or blue with the corresponding line colour a mixture of all three colours. This mode only supports up to 3 elements/orbitals combinations. The order of the selection tuple determines which colour is used for each selection.

    ”stacked”

    The element/orbital contributions are drawn as a series of stacked circles, with the colour depending on the composition of the band. The size of the circles can be scaled using the circle_size option.

  • normalise (str, optional) –

    Normalisation the projections. Options are:

    • 'all': Projections normalised against the sum of all

      other projections.

    • 'select': Projections normalised against the sum of the

      selected projections.

    • None: No normalisation performed.

  • interpolate_factor (int, optional) – The factor by which to interpolate the band structure (necessary to make smooth lines). A larger number indicates greater interpolation.

  • circle_size (float, optional) – The area of the circles used when mode = 'stacked'.

  • color1 (str) – A color specified in any way supported by matplotlib. Used when mode = 'rgb'.

  • color2 (str) – A color specified in any way supported by matplotlib. Used when mode = 'rgb'.

  • color3 (str) – A color specified in any way supported by matplotlib. Used when mode = 'rgb'.

  • colorspace (str) – The colorspace in which to perform the interpolation. The allowed values are rgb, hsv, lab, luvlc, lablch, and xyz. Used when mode = 'rgb'.

  • projection_cutoff (float) – Don’t plot projections with intensities below this number. This option is useful for stacked plots, where small projections clutter the plot.

  • zero_to_efermi (bool) – Normalise the plot such that the valence band maximum is set as 0 eV.

  • zero_line (bool, optional) – Draw a horizontal line at zero

  • zero_energy (float, optional) – Zero energy reference. (If unset, defaults to VBM or Fermi Energy as appropriate.)

  • ymin (float, optional) – The minimum energy on the y-axis.

  • ymax (float, optional) – The maximum energy on the y-axis.

  • width (float, optional) – The width of the plot.

  • height (float, optional) – The height of the plot.

  • vbm_cbm_marker (bool, optional) – Plot markers to indicate the VBM and CBM locations.

  • ylabel (str, optional) – y-axis (i.e. energy) label/units

  • dpi (int, optional) – The dots-per-inch (pixel density) for the image.

  • plt (matplotlib.pyplot, optional) – A matplotlib.pyplot object to use for plotting.

  • dos_plotter (SDOSPlotter, optional) – Plot the density of states alongside the band structure. This should be a SDOSPlotter object initialised with the data to plot.

  • dos_options (dict, optional) –

    The options for density of states plotting. This should be formatted as a dict containing any of the following keys:

    ”yscale” (float)

    Scaling factor for the y-axis.

    ”xmin” (float)

    The minimum energy to mask the energy and density of states data (reduces plotting load).

    ”xmax” (float)

    The maximum energy to mask the energy and density of states data (reduces plotting load).

    ”colours” (dict)

    Use custom colours for specific element and orbital combinations. Specified as a dict of dict of the colours. For example:

    {
         'Sn': {'s': 'r', 'p': 'b'},
         'O': {'s': '#000000'}
     }
    

    The colour can be a hex code, series of rgb value, or any other format supported by matplotlib.

    ”plot_total” (bool)

    Plot the total density of states. Defaults to True.

    ”legend_cutoff” (float)

    The cut-off (in % of the maximum density of states within the plotting range) for an elemental orbital to be labelled in the legend. This prevents the legend from containing labels for orbitals that have very little contribution in the plotting range.

    ”subplot” (bool)

    Plot the density of states for each element on separate subplots. Defaults to False.

  • dos_label (str, optional) – DOS axis label/units

  • plot_dos_legend (bool) – Whether to plot the dos legend.

  • dos_aspect (float, optional) – Aspect ratio for the band structure and density of states subplot. For example, dos_aspect = 3, results in a ratio of 3:1, for the band structure:dos plots.

  • aspect (float, optional) – The aspect ratio of the band structure plot. By default the dimensions of the figure size are used to determine the aspect ratio. Set to 1 to force the plot to be square.

  • fonts (list, optional) – Fonts to use in the plot. Can be a a single font, specified as a str, or several fonts, specified as a list of str.

  • style (list, str, or dict) – Any matplotlib style specifications, to be composed on top of Sumo base style.

  • no_base_style (bool, optional) – Prevent use of sumo base style. This can make alternative styles behave more predictably.

  • spin (Spin, optional) – Plot a spin-polarised band structure, “up” or “1” for spin up only, “down” or “-1” for spin down only. Defaults to None.

Returns:

The projected electronic band structure plot.

Return type:

matplotlib.pyplot

sumo.plotting.dos_plotter module

This module provides a class for plotting density of states data.

class sumo.plotting.dos_plotter.SDOSPlotter(dos, pdos=None)[source]

Bases: object

Class for plotting density of states data.

This class should be initialised with the total and partial density of states. The easiest way to generate the partial density of states is using the following method:

pdos = sumo.electronic_structure.dos.get_pdos()
Parameters:
  • dos (Dos) – The total density of states.

  • pdos (dict, optional) –

    The partial density of states. Formatted as a dict of dict mapping the elements and their orbitals to Dos objects. For example:

    {
        'Bi': {'s': Dos, 'p': Dos ... },
        'S': {'s': Dos}
    }
    

    Usually generated using the sumo.electronic_structure.dos.get_pdos() function.

dos_plot_data(yscale=1, xmin=-6.0, xmax=6.0, colours=None, plot_total=True, legend_cutoff=3, subplot=False, zero_to_efermi=True, zero_energy=None, cache=None, spin=None)[source]

Get the plotting data.

Parameters:
  • yscale (float, optional) – Scaling factor for the y-axis.

  • xmin (float, optional) – The minimum energy to mask the energy and density of states data (reduces plotting load).

  • xmax (float, optional) – The maximum energy to mask the energy and density of states data (reduces plotting load).

  • colours (dict, optional) –

    Use custom colours for specific element and orbital combinations. Specified as a dict of dict of the colours. For example:

    {
        'Sn': {'s': 'r', 'p': 'b'},
        'O': {'s': '#000000'}
    }
    

    The colour can be a hex code, series of rgb value, or any other format supported by matplotlib.

  • plot_total (bool, optional) – Plot the total density of states. Defaults to True.

  • legend_cutoff (float, optional) – The cut-off (in % of the maximum density of states within the plotting range) for an elemental orbital to be labelled in the legend. This prevents the legend from containing labels for orbitals that have very little contribution in the plotting range.

  • subplot (bool, optional) – Plot the density of states for each element on separate subplots. Defaults to False.

  • zero_to_efermi (bool, optional) – Normalise the plot such that the Fermi level is set as 0 eV.

  • zero_energy (float, optional) – If provided, this value is used as the 0 eV reference. Otherwise, behaviour depends on zero_to_efermi.

  • cache (dict, optional) – Cache object tracking how colours have been assigned to orbitals. The format is the same as the “colours” dict. This defaults to the module-level sumo.plotting.colour_cache object, but an empty dict can be used as a fresh cache. This object will be modified in-place.

  • spin (Spin, optional) – Check that spin-selection has not been called for a closed-shell calculation.

Returns:

The plotting data. Formatted with the following keys:

”energies” (numpy.ndarray)

The energies.

”mask” (numpy.ndarray)

A mask used to trim the density of states data and prevent unwanted data being included in the output file.

”lines” (list)

A list of dict containing the density data and some metadata. Each line dict contains the keys:

”label” (str)

The label for the legend.

”dens” (numpy.ndarray)

The density of states data.

”colour” (str)

The colour of the line.

”alpha” (float)

The alpha value for line fill.

”ymin” (float)

The minimum y-axis limit.

”ymax” (float)

The maximum y-axis limit.

Return type:

dict

get_plot(subplot=False, width=None, height=None, xmin=-6.0, xmax=6.0, yscale=1, colours=None, plot_total=True, legend_on=True, num_columns=2, legend_frame_on=False, legend_cutoff=3, xlabel='Energy (eV)', ylabel='DOS', zero_to_efermi=True, zero_line=False, zero_energy=None, dpi=400, fonts=None, plt=None, style=None, no_base_style=False, spin=None)[source]

Get a matplotlib.pyplot object of the density of states.

Parameters:
  • subplot (bool, optional) – Plot the density of states for each element on separate subplots. Defaults to False.

  • width (float, optional) – The width of the plot.

  • height (float, optional) – The height of the plot.

  • xmin (float, optional) – The minimum energy on the x-axis.

  • xmax (float, optional) – The maximum energy on the x-axis.

  • yscale (float, optional) – Scaling factor for the y-axis.

  • colours (dict, optional) –

    Use custom colours for specific element and orbital combinations. Specified as a dict of dict of the colours. For example:

    {
        'Sn': {'s': 'r', 'p': 'b'},
        'O': {'s': '#000000'}
    }
    

    The colour can be a hex code, series of rgb value, or any other format supported by matplotlib.

  • plot_total (bool, optional) – Plot the total density of states. Defaults to True.

  • legend_on (bool, optional) – Plot the graph legend. Defaults to True.

  • num_columns (int, optional) – The number of columns in the legend.

  • legend_frame_on (bool, optional) – Plot a frame around the graph legend. Defaults to False.

  • legend_cutoff (float, optional) – The cut-off (in % of the maximum density of states within the plotting range) for an elemental orbital to be labelled in the legend. This prevents the legend from containing labels for orbitals that have very little contribution in the plotting range.

  • xlabel (str, optional) – Label/units for x-axis (i.e. energy)

  • ylabel (str, optional) – Label/units for y-axis (i.e. DOS)

  • zero_to_efermi (bool, optional) – Normalise the plot such that the Fermi level is set as 0 eV.

  • zero_line (bool, optional) – Draw a line at 0 eV.

  • zero_energy (float, optional) – If provided, this value is used as the 0 eV reference. Otherwise, behaviour depends on zero_to_efermi.

  • dpi (int, optional) – The dots-per-inch (pixel density) for the image.

  • fonts (list, optional) – Fonts to use in the plot. Can be a a single font, specified as a str, or several fonts, specified as a list of str.

  • plt (matplotlib.pyplot, optional) – A matplotlib.pyplot object to use for plotting.

  • style (list, str, or dict) – Any matplotlib style specifications, to be composed on top of Sumo base style.

  • no_base_style (bool, optional) – Prevent use of sumo base style. This can make alternative styles behave more predictably.

  • spin (Spin, optional) – Plot a spin-polarised density of states, “up” or “1” for spin up only, “down” or “-1” for spin down only. Defaults to None.

Returns:

The density of states plot.

Return type:

matplotlib.pyplot

sumo.plotting.dos_plotter.get_cached_colour(element, orbital, colours=None, cache=None)[source]

Get a colour for a particular elemental and orbital combination.

If the element is not specified in the colours dictionary, the cache is checked. If this element-orbital combination has not been chached before, a new colour is drawn from the current matplotlib colour cycle and cached.

The default cache is sumo.plotting.colour_cache. To reset this cache, use sumo.plotting.colour_cache.clear().

Parameters:
  • element (str) – The element.

  • orbital (str) – The orbital.

  • colours (dict, optional) –

    Use custom colours for specific element and orbital combinations. Specified as a dict of dict of the colours. For example:

    {
        'Sn': {'s': 'r', 'p': 'b'},
        'O': {'s': '#000000'}
    }
    

    The colour can be a hex code, series of rgb value, or any other format supported by matplotlib.

  • cache (dict, optional) – Cache of colour values already assigned. The format is the same as the custom colours dict. If None, the module-level cache sumo.plotting.colour_cache is used.

Returns:

(colour, cache)

Return type:

tuple

sumo.plotting.optics_plotter module

This module provides a class for plotting optical absorption spectra.

class sumo.plotting.optics_plotter.SOpticsPlotter(spec_data, band_gap=None, label=None)[source]

Bases: object

Class for plotting optical spectra.

The easiest way to initialise this class is using the output from the sumo.electronic_structure.optics.calculate_alpha() method.

Parameters:
  • spec_data (dict or tuple or list) –

    The optical absorption spectra. Should be formatted as a dict of tuple of list:

    {property: ([energies], [alpha]), ...}
    

    Alternatively, the anisotropic (directional dependent) absorption can be plotted if the data formatted as:

    {property: ([energies], [alpha_xx, alpha_yy, alpha_zz]), ...}
    

    If a list of tuple is provided, then multiple absorption spectra can be plotted simultaneously.

    The property keys set the type of spectrum being plotted (and determine the y-axis label). Recognised values are ‘absorption’, ‘loss’, ‘eps-real’, ‘eps-im’. Other values will be plotted and used as the y-axis label.

    It is recommended to use an OrderedDict to get a predictable sequence of plotting axes (from top to bottom).

    If no dict at all is used (i.e. spec_data is a data tuple or a list of tuples) property will default to ‘abs’

  • band_gap (float or list, optional) – The band gap as a float, plotted as a dashed line. If plotting multiple spectra then a list of band gaps can be provided. If an item in the list is None no corresponding line is plotted.

  • label (str or list) – A label to identify the spectra. If plotting multiple spectra then a list of labels can be provided.

get_plot(units='eV', width=None, height=None, xmin=0.0, xmax=None, ymin=0, ymax=None, colours=None, dpi=400, plt=None, fonts=None, style=None, no_base_style=False)[source]

Get a matplotlib.pyplot object of the optical spectra.

Parameters:
  • units (str, optional) – X-axis units for the plot. ‘eV’ for energy in electronvolts or ‘nm’ for wavelength in nanometers. Defaults to ‘eV’.

  • width (float, optional) – The width of the plot.

  • height (float, optional) – The height of the plot.

  • xmin (float, optional) – The minimum energy on the x-axis.

  • xmax (float, optional) – The maximum energy on the x-axis.

  • ymin (float, optional) – The minimum absorption intensity on the y-axis.

  • ymax (float, optional) – The maximum absorption intensity on the y-axis.

  • colours (list, optional) – A list of colours to use in the plot. The colours can be specified as a hex code, set of rgb values, or any other format supported by matplotlib.

  • dpi (int, optional) – The dots-per-inch (pixel density) for the image.

  • plt (matplotlib.pyplot, optional) – A matplotlib.pyplot object to use for plotting.

  • fonts (list, optional) – Fonts to use in the plot. Can be a a single font, specified as a str, or several fonts, specified as a list of str.

  • style (list, str, or dict) – Any matplotlib style specifications, to be composed on top of Sumo base style.

  • no_base_style (bool, optional) – Prevent use of sumo base style. This can make alternative styles behave more predictably.

Returns:

The plot of optical spectra.

Return type:

matplotlib.pyplot

sumo.plotting.optics_plotter.ev_to_nm(energy_ev)[source]

sumo.plotting.phonon_bs_plotter module

This module provides a class for plotting phonon band structure diagrams.

class sumo.plotting.phonon_bs_plotter.SPhononBSPlotter(bs, imag_tol=-0.05)[source]

Bases: PhononBSPlotter

Class for plotting phonon band structures.

This class is similar to the pymatgen.phonon.plotter.PhononBSPlotter class but overrides some methods to generate prettier plots.

Parameters:

bs (PhononBandStructureSymmLine) – The phonon band structure.

get_plot(units='THz', ymin=None, ymax=None, width=None, height=None, dpi=None, plt=None, fonts=None, dos=None, dos_aspect=3, color=None, style=None, no_base_style=False, from_json=None, legend=None)[source]

Get a matplotlib.pyplot object of the phonon band structure.

Parameters:
  • units (str, optional) – Units of phonon frequency. Accepted (case-insensitive) values are Thz, cm-1, eV, meV.

  • ymin (float, optional) – The minimum energy on the y-axis.

  • ymax (float, optional) – The maximum energy on the y-axis.

  • width (float, optional) – The width of the plot.

  • height (float, optional) – The height of the plot.

  • dpi (int, optional) – The dots-per-inch (pixel density) for the image.

  • fonts (list, optional) – Fonts to use in the plot. Can be a a single font, specified as a str, or several fonts, specified as a list of str.

  • plt (matplotlib.pyplot, optional) – A matplotlib.pyplot object to use for plotting.

  • dos (np.ndarray) – 2D Numpy array of total DOS data

  • dos_aspect (float) – Width division for vertical DOS

  • color (str or tuple, optional) – Line/fill colour in any matplotlib-accepted format

  • style (list, str, or dict) – Any matplotlib style specifications, to be composed on top of Sumo base style.

  • no_base_style (bool, optional) – Prevent use of sumo base style. This can make alternative styles behave more predictably.

  • from_json (list or None, optional) – List of paths to pymatgen.phonon.bandstructure.PhononBandStructureSymmline JSON dump files. These are used to generate additional plots displayed under the data attached to this plotter. The k-point path should be the same as the main plot; the reciprocal lattice is adjusted to fit the scaling of the main data input.

Returns:

The phonon band structure plot.

Return type:

matplotlib.pyplot