This is all about how to use the matplotlib library it tells us all about the graphical representation of data you can look at the graph od cosine which is made by using matplotlib library. If we talk about the usage of NUMPY library its use it to show the data in matrix form which is the most important thing indirectly we can say that they both are another form of MATLAB.
STEPS are just install numpy library as well as matplotlib
If we execute the above programme we can get the two graph within one subplot so that we can easily execute the number of graphs in a single plot diagram
STEPS are just install numpy library as well as matplotlib
import numpy as np import matplotlib.pyplot as plt t = np.arange(0.0,2.0,0.01) s = 1+np.cos(2*np.pi*t) plt.plot(t,s,'g') plt.xlabel('time') plt.ylabel('voltage') plt.title('cosine wave') plt.show()
import numpy as np import matplotlib.pyplot as plt x1 = np.linspace(0.0,5.0) x2 = np.linspace(0.0,2.0) y1 = np.cos(2*np.pi*x1)*np.exp(-x1) y2 = np.cos(2*np.pi*x2) plt.subplot(2,1,1) plt.plot(x1,y1,'o-') # by changing o- you can get various types of designplt.title('subplot-1') plt.xlabel('x1') plt.ylabel('amo(y1)') plt.subplot(2,1,2) plt.plot(x2,y2,'.-') # here also by changing .- u can get various kinds of designplt.title('subplot-2') plt.xlabel('x2') plt.ylabel('amp(y2)') plt.show()
If we execute the above programme we can get the two graph within one subplot so that we can easily execute the number of graphs in a single plot diagram