pymatgen.util.plotting_utils module

add_fig_kwargs(func)[source]

Decorator that adds keyword arguments for functions returning matplotlib figures.

The function should return either a matplotlib figure or None to signal some sort of error/unexpected event. See doc string below for the list of supported options.

get_ax3d_fig_plt(ax=None)[source]

Helper function used in plot functions supporting an optional Axes3D argument. If ax is None, we build the matplotlib figure and create the Axes3D else we return the current active figure.

Returns:Axes object figure: matplotlib figure plt: matplotlib pyplot module.
Return type:ax
get_ax_fig_plt(ax=None)[source]

Helper function used in plot functions supporting an optional Axes argument. If ax is None, we build the matplotlib figure and create the Axes else we return the current active figure.

Returns:Axes object figure: matplotlib figure plt: matplotlib pyplot module.
Return type:ax
get_axarray_fig_plt(ax_array, nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True, subplot_kw=None, gridspec_kw=None, **fig_kw)[source]

Helper function used in plot functions that accept an optional array of Axes as argument. If ax_array is None, we build the matplotlib figure and create the array of Axes by calling plt.subplots else we return the current active figure.

Returns:Array of Axes objects figure: matplotlib figure plt: matplotlib pyplot module.
Return type:ax
get_publication_quality_plot(width=8, height=None, plt=None, dpi=None, color_cycle=('qualitative', 'Set1_9'))[source]

Provides a publication quality plot, with nice defaults for font sizes etc.

Parameters:
  • width (float) – Width of plot in inches. Defaults to 8in.
  • height (float) – Height of plot in inches. Defaults to width * golden ratio.
  • plt (matplotlib.pyplot) – If plt is supplied, changes will be made to an existing plot. Otherwise, a new plot will be created.
  • dpi (int) – Sets dot per inch for figure.
  • color_cycle (tuple) – Set the color cycle for new plots to one of the color sets in palettable. Defaults to a qualitative Set1_9.
Returns:

Matplotlib plot object with properly sized fonts.