lin_fit

Signature

lin_fit(
    x: ArrayLike,
    y: ArrayLike,
    sigma_y: ArrayLike,
    *,
    sigma_x: ArrayLike | None = None,
    tol: float = 1e-10,
    max_iter: int = 100,
    style: str | None = "mespy",
    xlabel: str = "x [xu]",
    ylabel: str = "y [uy]",
    title: str | None = None,
    decimals: int = 3,
    show_plot: bool = True,
    show_band: bool = True,
    show_legend: bool = True,
    show_fit_params: bool = False,
    show_grid: bool = True,
    xlim: ArrayLike | None = None,
    ylim: ArrayLike | None = None,
    figsize: ArrayLike | None = None,
    dpi: int | None = None,
    save_path: str | None = None,
    title_fontsize: int | float | None = None,
    title_pad: int | float | None = None,
    legend_fontsize: int | float | None = None,
    legend_loc: str | None = None,
    point_color: str | None = None,
    fit_color: str = "#D65F5F",
    band_color: str = "#EE854A",
    data_alpha: float = 1.0,
    band_alpha: float = 0.20,
    grid_alpha: float | None = None,
) -> LinearFitResult

lin_fit performs a weighted linear fit y = m x + c on experimental data, with optional support for uncertainties on x as well.

By default it applies the mespy Matplotlib style; pass style=None to use the current rcParams, or the name of another style to delegate to Matplotlib.

The figsize, dpi, title_fontsize, title_pad, legend_fontsize, legend_loc, point_color, and grid_alpha parameters can inherit from the active style when left as None. The fit_color, band_color, data_alpha, and band_alpha parameters remain explicit per-call overrides instead.

This page remains the quick access point for the function. Practical details are collected in Overview, while How it works is prepared as a separate subpage.