graphinglib.FitFromPolynomial.__init__#

FitFromPolynomial.__init__(curve_to_be_fit: Curve | Scatter, degree: int, label: str | None = None, color: str | Inherit = Inherit, line_width: int | Inherit = Inherit, line_style: int | Inherit = Inherit, alpha: float | Inherit = Inherit) None[source]#

Creates a curve fit (continuous Curve) from an existing curve object using a polynomial fit.

Fits a polynomial of the form \(f(x) = a_0 + a_1 x + a_2 x^2 + ... + a_n x^n\) to the given curve. All standard Curve attributes and methods are available.

Parameters:
curve_to_be_fitCurve or Scatter

The object to be fit.

degreeint

Degree of the polynomial fit.

labelstr, optional

Label to be displayed in the legend.

colorstr

Color of the Curve. Default depends on the figure_style configuration.

line_widthint

Line width of the Curve. Typical range is 0.5 to 4. Default depends on the figure_style configuration.

line_stylestr

Line style of the Curve. Values include "-", "--", "-.", ":", "solid", "dashed", "dashdot", and "dotted". Default depends on the figure_style configuration.

alphafloat

Opacity of the Curve. Range is 0 (transparent) to 1 (opaque). Default depends on the figure_style configuration.

Attributes:
coeffsnp.ndarray

Coefficients of the polynomial fit. The first element is the coefficient of the lowest order term (constant term).

cov_matrixnp.ndarray

Covariance matrix of the polynomial fit (using the same order as the coeffs attribute).

standard_deviationnp.ndarray

Standard deviation of the coefficients of the polynomial fit (same order as coeffs).

functionCallable

Polynomial function with the parameters of the fit.

Notes

Color parameters accept Matplotlib color formats: named colors ("blue"), short color strings ("b"), hex strings ("#0000ff"), grayscale strings ("0.5"), and RGB/RGBA tuples with values between 0 and 1 ((0, 0, 1) or (0, 0, 1, 0.5)).