graphinglib.FitFromFunction.from_function#

classmethod FitFromFunction.from_function(func: Callable[[TypeAliasForwardRef('ArrayLike')], TypeAliasForwardRef('ArrayLike')], x_min: float, x_max: float, label: str | None = None, color: str | Inherit = Inherit, line_width: float | Inherit = Inherit, line_style: str | Inherit = Inherit, alpha: float | Inherit = Inherit, number_of_points: int = 500) Self#

Creates a Curve from a function and a range of x values.

Parameters:
funcCallable[[ArrayLike], ArrayLike]

Function to be plotted. Works with regular functions and lambda functions.

x_min, x_maxfloat

The Curve will be plotted between these two values.

labelstr, optional

Label to be displayed in the legend.

colorstr

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

line_widthfloat

Width of the curve. Typical range is 0.5 to 4. Default depends on the figure_style configuration.

line_stylestr

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.

number_of_pointsint

Number of points to be used to plot the curve (resolution). Defaults to 500.

Returns:
A Curve object created from the given function and x range.

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)).