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:
  • fig (Figure) – Matplotlib figure to save.

  • filename (str) – Name of the file to save the figure to.

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:
  • ax1 (Axes) – First axis.

  • ax2 (Axes) – Second axis.

References

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

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

Parameters:

axes (list[plt.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

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