Friday, February 4, 2022

Python - plot sine cos tan function


 Plotting sin(x), cose(x), tan(x0 in single single plot


Python code:


import matplotlib.pyplot as plt
#import matplotlibrary for plotting
import numpy as np
# importing numpy module for math functions

x = np.arange(0,4*np.pi,0.1)  
# (start,stop,step)

plt.plot(x,np.sin(x),x,np.cos(x),x,np.tan(x))
#(x,y,x,y,x,y)
plt.ylim(-5,5)
#(lower,highest)
plt.legend(["sin(x)", "cos(x)", "tan(x)"],
loc ="lower right")
# ([legend name], location)
plt.title("sin(x),cos(x),tan(x) Vs Angle")
# (title name)
plt.xlabel('Angle in rad')
# (x label name)
plt.show()
# disp plot

Result



Python - plot sine cos tan function

 Plotting sin(x), cose(x), tan(x0 in single single plot Python code: import matplotlib . pyplot as plt #import matplotlibrary for plotti...