python 绘制三角函数图形 sin、con、arcsin、arccos

1、正弦和余弦的图形

import numpy as np
from matplotlib import pyplot as plt

%matplotlib notebook

x = np.linspace((-np.pi)*2, np.pi*2, 50, endpoint=True)
y1, y2 = np.sin(x), np.cos(x)

plt.plot(x, y1, c='g', marker='s', label='sin(x)')
plt.plot(x, y2, c='r', marker='o', label='con(x)')
plt.legend(loc='upper left', numpoints=2,)

 

 

2、反正弦和反余弦的图形

import numpy as np
from matplotlib import pyplot as plt

%matplotlib notebook

x = np.linspace(-4, 4, 100)
y1, y2 = np.arcsin(x), np.arccos(x)

plt.plot(x, y1, c='b', marker='s', label='arcsin(x)')
plt.plot(x, y2, c='r', marker='o', label='arccon(x)')
plt.legend(loc='upper right', numpoints=2,)
plt.ylim(-4, 4)

posted @ 2020-01-22 23:12  赏尔  阅读(3628)  评论(0编辑  收藏  举报