rizer.misc.plt_utils#

Functions#

set_mpl_style(→ None)

Set the matplotlib style for plots.

save_current_figure(→ None)

Save the current figure to a file in the figures folder.

align_yaxis_np(→ None)

Align zeros of the two axes, zooming them out by same ratio.

align_zeros(→ None)

Align zeros of multiple axes, zooming them out by same ratio.

get_species_in_latex(→ str)

Return the LaTeX representation of a chemical species.

Module Contents#

rizer.misc.plt_utils.set_mpl_style(nb_columns: int = 2) None#

Set the matplotlib style for plots.

Parameters:

nb_columns (int, optional) – Number of columns for the figure style. Options are 1 or 2. By default 2.

rizer.misc.plt_utils.save_current_figure(fig: matplotlib.figure.Figure, filename: str) None#

Save the current figure to a file in the figures folder.

Parameters:
rizer.misc.plt_utils.align_yaxis_np(ax1: matplotlib.axes.Axes, ax2: matplotlib.axes.Axes) None#

Align zeros of the two axes, zooming them out by same ratio.

Script taken from [SSO_shared_origin].

Parameters:

References

rizer.misc.plt_utils.align_zeros(axes: list[matplotlib.axes.Axes]) None#

Align zeros of multiple axes, zooming them out by same ratio.

Parameters:

axes (list of matplotlib.axes.Axes) – List of axes to align.

Notes

This function modifies the y-limits of the axes in place. It ensures that all axes have the same zero point and that the y-limits are adjusted to fit the data while maintaining the zero alignment.

References

https://stackoverflow.com/a/68869054

rizer.misc.plt_utils.get_species_in_latex(species: str) str#

Return the LaTeX representation of a chemical species.

Parameters:

species (str) – Chemical species as a string.

Returns:

LaTeX representation of the chemical species.

Return type:

str

Examples

>>> get_species_in_latex("O2")
'$\\mathregular{O_{2}}$'
>>> get_species_in_latex("CH4")
'$\\mathregular{CH_{4}}$'
>>> get_species_in_latex("CH4+")
'$\\mathregular{CH_{4}^{+}}$'
>>> get_species_in_latex("e-")
'$\\mathregular{e^{-}}$'
>>> get_species_in_latex("C2H6")
'$\\mathregular{C_{2}H_{6}}$'
>>> get_species_in_latex("C++")
'$\\mathregular{C^{++}}$'
>>> get_species_in_latex("C(soot)")
'$\\mathregular{C}(\\mathregular{soot})$'
>>> get_species_in_latex("C(s)")
'$\\mathregular{C}(\\mathregular{s})$'
>>> get_species_in_latex("C+")
'$\\mathregular{C^{+}}$'
>>> get_species_in_latex("C++")
'$\\mathregular{C^{++}}$'
>>> get_species_in_latex("C+++")
'$\\mathregular{C^{3+}}$'