NumPy
numpy.org › doc › stable › reference › generated › numpy.linspace.html
numpy.linspace — NumPy v2.5 Manual
>>> import matplotlib.pyplot as plt >>> N = 8 >>> y = np.zeros(N) >>> x1 = np.linspace(0, 10, N, endpoint=True) >>> x2 = np.linspace(0, 10, N, endpoint=False) >>> plt.plot(x1, y, 'o') [<matplotlib.lines.Line2D object at 0x...>] >>> plt.plot(x2, y + 0.5, 'o') [<matplotlib.lines.Line2D object at 0x...>] >>> plt.ylim([-0.5, 1]) (-0.5, 1) >>> plt.show()
Stack Overflow
stackoverflow.com › questions › 32208359 › is-there-a-multi-dimensional-version-of-arange-linspace-in-numpy
python - Is there a multi-dimensional version of arange/linspace in numpy? - Stack Overflow
I would like a list of 2d NumPy arrays (x,y) , where each x is in {-5, -4.5, -4, -3.5, ..., 3.5, 4, 4.5, 5} and the same for y. I could do x = np.arange(-5, 5.1, 0.5) y = np.arange(-5, 5.1, 0.5)...
NumPy
numpy.org › devdocs › › reference › generated › numpy.linspace.html
numpy.linspace — NumPy v2.6.dev0 Manual
>>> import matplotlib.pyplot as plt >>> N = 8 >>> y = np.zeros(N) >>> x1 = np.linspace(0, 10, N, endpoint=True) >>> x2 = np.linspace(0, 10, N, endpoint=False) >>> plt.plot(x1, y, 'o') [<matplotlib.lines.Line2D object at 0x...>] >>> plt.plot(x2, y + 0.5, 'o') [<matplotlib.lines.Line2D object at 0x...>] >>> plt.ylim([-0.5, 1]) (-0.5, 1) >>> plt.show()
DataCamp
datacamp.com › home › tutorials › python › how to use the numpy linspace() function
How to Use the NumPy linspace() Function | DataCamp
April 5, 2024 - linspace() is also useful for generating multi-dimensional arrays. Here, we show a few examples of that in action. This example illustrates how to generate a 2D array where each row transitions smoothly from the vector [0, 10] to [5, 15], creating a gradient effect over 4 steps. import numpy ...
TutorialsPoint
tutorialspoint.com › numpy › numpy_linspace_function.htm
Numpy linspace() Function
Using the numpy.linspace() function, ... array by specifying the number of equally spaced values over a given range and then reshaping the resulting 1-dimensional array into the desired 2-dimensional shape using reshape() function...
Real Python
realpython.com › np-linspace-numpy
np.linspace(): Create Evenly or Non-Evenly Spaced Arrays – Real Python
July 3, 2026 - When you’re working with numerical applications using NumPy, you often need to create an array of numbers. In many cases you want the numbers to be evenly spaced, but there are also times when you may need non-evenly spaced numbers. One of the key tools you can use in both situations is np.linspace().
Medium
heartbeat.comet.ml › exploring-numpys-linspace-function-bb3378f8dcd8
Exploring NumPy’s linspace() function | by Ahmed Gad | Heartbeat
September 28, 2021 - You can think of the 1D array we created above as a 2D array in which the size of the first dimension is 5 but the size of the second dimension is just 1, and thus the array size is 5x1. In this section, we’ll increase the size of the second dimension. import numpy as np arr_1D = np.linspace(start=1, stop=5, num=5) print(arr_1D) print("Array Shape =", arr_1D.shape)[1.
Kanaries
docs.kanaries.net › topics › NumPy › numpy-linspace
NumPy Linspace: How to Create Evenly Spaced Arrays in Python – Kanaries
February 9, 2026 - More points increase memory usage and rendering time, so balance smoothness against performance. numpy.linspace() is one of the most frequently used NumPy functions for a reason: it gives you precise control over how many evenly spaced values you generate between two endpoints.
NumPy
numpy.org › doc › 1.18 › reference › generated › numpy.linspace.html
numpy.linspace — NumPy v1.18 Manual
>>> import matplotlib.pyplot as plt >>> N = 8 >>> y = np.zeros(N) >>> x1 = np.linspace(0, 10, N, endpoint=True) >>> x2 = np.linspace(0, 10, N, endpoint=False) >>> plt.plot(x1, y, 'o') [<matplotlib.lines.Line2D object at 0x...>] >>> plt.plot(x2, y + 0.5, 'o') [<matplotlib.lines.Line2D object at 0x...>] >>> plt.ylim([-0.5, 1]) (-0.5, 1) >>> plt.show()
NumPy
numpy.org › doc › stable › user › how-to-partition.html
How to create arrays with regularly-spaced values — NumPy v2.5 Manual
Use numpy.linspace if you want the endpoint to be included in the result, or if you are using a non-integer step size.
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.linspace.html
numpy.linspace — NumPy v2.1 Manual
>>> import matplotlib.pyplot as plt >>> N = 8 >>> y = np.zeros(N) >>> x1 = np.linspace(0, 10, N, endpoint=True) >>> x2 = np.linspace(0, 10, N, endpoint=False) >>> plt.plot(x1, y, 'o') [<matplotlib.lines.Line2D object at 0x...>] >>> plt.plot(x2, y + 0.5, 'o') [<matplotlib.lines.Line2D object at 0x...>] >>> plt.ylim([-0.5, 1]) (-0.5, 1) >>> plt.show()
NumPy
numpy.org › doc › 1.23 › reference › generated › numpy.linspace.html
numpy.linspace — NumPy v1.23 Manual
>>> import matplotlib.pyplot as plt >>> N = 8 >>> y = np.zeros(N) >>> x1 = np.linspace(0, 10, N, endpoint=True) >>> x2 = np.linspace(0, 10, N, endpoint=False) >>> plt.plot(x1, y, 'o') [<matplotlib.lines.Line2D object at 0x...>] >>> plt.plot(x2, y + 0.5, 'o') [<matplotlib.lines.Line2D object at 0x...>] >>> plt.ylim([-0.5, 1]) (-0.5, 1) >>> plt.show()
NumPy
numpy.org › doc › stable › user › basics.creation.html
Array creation — NumPy v2.5 Manual
>>> import numpy as np >>> np.linspace(1., 4., 6) array([1. , 1.6, 2.2, 2.8, 3.4, 4. ]) The advantage of this creation function is that you guarantee the number of elements and the starting and end point. The previous arange(start, stop, step) will not include the value stop. The 2D array creation functions e.g.