graphinglib.FitFromPolynomial.__init__#
- FitFromPolynomial.__init__(curve_to_be_fit: Curve | Scatter, degree: int, label: str | None = None, color: str = 'default', line_width: int | Literal['default'] = 'default', line_style: int | Literal['default'] = 'default') 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_fit
Curve
orScatter
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 thefigure_style
configuration.- line_widthint
Line width of the
Curve
. Default depends on thefigure_style
configuration.- line_stylestr
Line style of the
Curve
. Default depends on thefigure_style
configuration.
- curve_to_be_fit
- 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.