Plot of sin , cos and tan graph using Python :
In trigonometry , we always hear about sin , cos and tan function also sin is start from zero and cos is start from 1 and ranging and tan function that starts from zero and ranging to infinity . Python and its scientific module such as numpy and matplotlib will help us to visualise those graph.
Source Code :
import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(0,15,1000) # value of x
y=np.sin(x)
y1=np.cos(x)
y2=np.tan(x)
""" ###### PLOT SIN AND COS GRAPH ###### """
plt.subplot(1,2,1)
plt.plot(x,y,c='b',label = "sin (x)")
plt.plot(x,y1,c='r',label = "cos (x)")
plt.axhline(0 ,color="black")
plt.legend(loc='best' , prop={'size':12})
plt.xlim(0,15)
""" ###### PLOT TAN GRAPH ##### """
plt.subplot(1,2,2)
plt.plot(x,y2,c='c', label = "tan (x)")
plt.ylim(-10,10)
plt.axhline(0 , color="black")
plt.legend(loc='best' , prop={'size':12})
plt.suptitle("Visualization of sin , cos and tan graph",fontsize=18,color='b',fontstyle ="italic")
plt.show()
Share: