graphinglib.VectorField.from_function#
- classmethod VectorField.from_function(func: Callable[[ArrayLike, ArrayLike], tuple[ArrayLike, ArrayLike]], x_axis_range: tuple[float, float], y_axis_range: tuple[float, float], number_of_arrows_x: int = 10, number_of_arrows_y: int = 10, arrow_width: float | Literal['default'] = 'default', arrow_head_size: float | Literal['default'] = 'default', scale: float | None = None, make_angles_axes_independent: bool = False, color: str | Literal['default'] = 'default') Self [source]#
Creates a
VectorField
from a function.- Parameters:
- funcCallable[[ArrayLike, ArrayLike], tuple[ArrayLike, ArrayLike]]
Function to be plotted. Works with regular functions and lambda functions.
- x_data, y_dataArrayLike
x and y coordinates of the vectors.
- u_data, v_dataArrayLike
Magnitudes in the x and y coordinates.
- number_of_arrows_x, number_of_arrows_yint
Number of arrows to plot in the x and y direction. Defaults to 10.
- arrow_widthfloat
Width of the arrow shaft. Acts as a multiplier for the standard arrow width. Default depends on the
figure_style
configuration.- arrow_head_sizefloat
Size of the arrow head. Acts as a multiplier for the standard arrow head size. Default depends on the
figure_style
configuration.- scalefloat
Scaling of the arrow lengths. If
None
, the arrows will be automatically scaled to look nice. Use 1 for no scaling. Default isNone
.- make_angles_axes_independentbool
Whether to use the screen coordinates or the data coordinates to determine the vector directions. If
True
, vectors with u = v will always appear as 45 degree angles with respect to the screen, regardless of the axes limits. IfFalse
, the vectors will scale with the aspect ratio of the axes. Defaults toFalse
.- colorstr
Color of the vector arrows. Default depends on the
figure_style
configuration.
- Returns:
- A
VectorField
object from a function.
- A