Numpy linspace function

To create e.g. x-axis indices you can use the linspace function from numpy.

You give it a range (e.g. 0 to 10) and the number of divisions and it will distribute the values evenly across that range. The stop values is included in the resulting value array by default.

Example:

>>import numpy as np
>>np.linspace(0, 10, num=9)
>>array([ 0. , 1.25, 2.5 , 3.75, 5. , 6.25, 7.5 , 8.75, 10. ]

Leave a Reply

Your email address will not be published. Required fields are marked *