diff --git a/src/scgenerator/plotting.py b/src/scgenerator/plotting.py index c502157..31ef28c 100644 --- a/src/scgenerator/plotting.py +++ b/src/scgenerator/plotting.py @@ -1155,6 +1155,16 @@ def annotate_fwhm( ax.text(x, y, arrow_label, transform=trans, **text_kwargs) +def auto_time_range(t: np.ndarray, t_int: np.ndarray, threshold: float) -> PlotRange: + imin, imax = math.span_above(t_int, t_int.max() * threshold) + return PlotRange(t[imin] * 1e15, t[imax] * 1e15, "fs") + + +def auto_wl_range(wl: np.ndarray, wl_int: np.ndarray, threshold: float) -> PlotRange: + imin, imax = math.span_above(wl_int, wl_int.max() * threshold) + return PlotRange(wl[imin] * 1e9, wl[imax] * 1e9, "nm") + + def summary_plot( specs: Spectrum, z: Sequence[float] | None = None,