数学中三角函数有sinx, cosx, tanx, cotx,请将此四个三角函数的图像画在一张图里的多个子图里。
import numpy as np import matplotlib.pyplot as plt from pylab import * x = np.arange(-2*np.pi,2*np.pi,0.01) plt.xlim(-2*np.pi,np.max(x)) subplot(2,1,1) plt.plot(x,np.sin(x),color='red',label='$sinx$') plt.grid() plt.legend() plt.show() subplot(2,1,1) plt.plot(x,np.cos(x),color='blue',label='$cosx$') plt.grid() plt.legend() plt.show() subplot(2,1,1) plt.ylim(-3,3) plt.plot(x,np.sin(x)/np.cos(x),color='yellow',label='$tanx$') plt.grid() plt.legend() plt.show() subplot(2,1,1) plt.ylim(-3,3) plt.plot(x,np.cos(x)/np.sin(x),color='green',label='$cotx$') plt.grid() plt.legend() plt.show()



