from_function#

classmethod DataXY.from_function(f, x, title='', xlabel='', ylabel='', **fkwargs)[source]#

Instantiate from a function.

Parameters:
fCallable

y-data will be f(x, **fkwargs).

xarray_like

x-points at which f will be evaluated.

titlestr, default “”

Optional title of the data.

xlabelstr, default “”

Optional x-label of the data.

ylabelstr, default “”

Optional y-label of the data.

**fkwargs

Other keyword arguments will be passed to f.

Returns:
DataXY

Examples

>>> data = ap.DataXY.from_function(lambda x : x**2, (0, 1, 2))
>>> data.x
array([0., 1., 2.])
>>> data.y
array([0., 1., 4.])