plot_xsecs
plot_xsecs(reactions, *, processes="all", layout="overlay", energy_unit="eV", xsec_unit="Mb", energy_log=True, xsecs_log=True, trim=True, shade=False, show_bands=False, palette=None, title=None, fig=None, ax=None, grid=True, show=True, save=False, filename="")
Plots photo cross sections for one or more reactions on shared axes. Handles
unit conversion, log scaling, axis trimming, optional shading, and optional
band-averaged bars. Reactions without cross-section data are skipped with a log
message; returns None if nothing can be drawn.
Parameters
- reactions : reaction-like or list of reaction-like
- A single reaction (anything exposing
xsecs_dictandband_xsecs) or a list of them. Their cross sections are overlaid. - processes : str or list[str] or None, optional
- Which processes to draw.
"all"(default) orNoneplots every process with data; a single key or list selects a subset. Valid keys:"photo_absorption","photodecay". An invalid key raisesKeyError. - layout : str, optional
"overlay"(default) draws all curves on one axes;"subplots"gives each curve its own stacked panel.- energy_unit : str, optional
- Horizontal-axis unit:
"eV"(default),"erg","nm", or"um". - xsec_unit : str, optional
- Cross-section unit:
"Mb"(default),"cm^2", or"barn". - energy_log, xsecs_log : bool, optional
- Log-scale the energy / cross-section axis. Default
True. - trim : bool, optional
- Tighten the energy axis to the positive data span. Default
True. - shade : bool or float, optional
- Shade the area under each curve.
Trueuses a default alpha; a float sets the alpha explicitly. DefaultFalse. - show_bands : bool, optional
- Overlay the band-averaged cross section as bars for every reaction that has them (see
Reaction.band_xsecs). DefaultFalse. - palette : list[str] or None, optional
- Colour-cycle override.
- title : str or None, optional
- Plot title. Defaults to the LaTeX equation for a single reaction, else empty.
- fig, ax : matplotlib.figure.Figure / matplotlib.axes.Axes or None, optional
- Existing figure/axes to draw on (overlay only). Created if
None. - grid, show, save, filename : optional
- Standard rendering controls.
Returns
- tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] or None
- The figure and axes (overlay) or array of axes (subplots);
Nonewhen no reaction has cross-section data.
Note
With a single reaction the legend uses the process names; with several it prefixes each with the reaction so curves stay distinguishable.
Examples
from jaff.plotting import plot_xsecs
photo = net.reactions.photo_reactions()[0]
plot_xsecs(photo) # one reaction, all processes
plot_xsecs(photo, shade=True, show_bands=True) # shading + band bars
plot_xsecs(photo, energy_unit="nm", xsec_unit="cm^2")
plot_xsecs(net.reactions.photo_reactions()) # overlay several reactions