linspace#
- named_arrays.linspace(start, stop, axis, num=50, endpoint=True, dtype=None, centers=False)#
Create an array of evenly-spaced numbers between start and stop.
- Parameters:
start (StartT) – The starting value of the sequence
stop (StopT) – The last value of the sequence, unless
endpointisFalseaxis (AxisT) – The name of the new axis corresponding to the sequence
num (NumT) – Number of values in the sequence
endpoint (bool) – Flag controlling whether
stopshould be included in the sequence.dtype (None | type | dtype) –
numpy.dtypeof the resultcenters (bool) – Flag controlling whether the returned values should be on cell centers. The default is to return values on cell edges.
- Return type:
StartT | StopT | AxisT | NumT
See also
numpy.linspace()Corresponding numpy function.
named_arrays.ScalarLinearSpaceCorresponding implicit scalar array.
named_arrays.UncertainScalarLinearSpaceCorresponding implicit uncertain scalar array.
Examples
Compare the points returned using
centers=Falseto those returned usingcenters=True.import named_arrays as na import matplotlib.pyplot as plt # Define an array of cell edges edges_x = na.linspace(0, 1, axis="x", num=11) edges_y = na.linspace(0, 1, axis="y", num=11) # Define an array of cell centers centers_x = na.linspace(0, 1, axis="x", num=10, centers=True) centers_y = na.linspace(0, 1, axis="y", num=10, centers=True) # Plot the results as a scatterplot fig, ax = plt.subplots() na.plt.scatter(edges_x, edges_y, ax=ax, label="edges"); na.plt.scatter(centers_x, centers_y, ax=ax, label="centers"); ax.legend();