import pylab import numpy x = numpy.linspace(-15,15,100) # 100 linearly spaced numbers y = numpy.sin(x)/x # computing the values of sin(x)/x # compose plot pylab.plot(x,y) # sin(x)/x pylab.plot(x,y,'co') # same function with cyan dots pylab.plot(x,2*y,x,3*y) # 2*sin(x)/x and 3*sin(x)/x pylab.show() # show the plotThe command pylab.show() will open a window with the following plot:
Great help thank you!
ReplyDeletethank you !!
ReplyDeleteTHANKS!
ReplyDeleteVery good info, thanks!!!
ReplyDeleteHow to realize it without numpy?!
ReplyDeleteIt's easy, you just need to generate the vectors x and y in another way. For example, x = [a*1.0 for a in range(0,10)] and y = [sin(xx) for xx in x].
DeleteIs it possible to plot a function and not just an equation?
ReplyDeleteGreat !!!
ReplyDeleteHow to plot something like the following equation?
ReplyDelete(x+y−2)^2
Hi Divij, here's an example that can hep you: https://glowingpython.blogspot.co.uk/2012/01/how-to-plot-two-variable-functions-with.html
DeleteThanks for the code, that helped a lot and gave some idea about what to use etc. But what I'm wondering is , do we really need to use only standart functions that have defined by Numpy? Or can we define a function ourselves and use it in numpy function too ?
ReplyDeleteThanks anyways, good code
Great but it's easy...
ReplyDelete