Linspace()

##### Title

##### Question

What is the use of linspace() function? Why it is used with plot()?

Python Using-the-plot-command-interactively 08-09 min 20-30 sec

__Answers:__

linspace() is a tool in Python for creating numeric sequences. linspace function creates

sequences of evenly spaced values within a defined interval. You can then plot those values

on canvas using .plot() function.

In python linspace() is used to create sequences of evenly spaced values within a defined interval. we need to specify a starting point and ending point of interval and then total no.of points you want in that interval.e.g. linspace(start=0,stop=5,num=10)-This will generate a numpy array of ten points as 0,0.5,1.0,1.5...and so on.

When we want to generate a plot , we require some input to be provided . suppose you want to generate a plot for sin() function , we can provide the output of linspace as input for the sin() function.

p1=numpy.linspace(0,2,10)

plot(p1.sin(p1)

This will generate a sin() plot.

Login to add comment