- 李萨如图形
import numpy as np
from matplotlib.pyplot import plot
from matplotlib.pyplot import show
a = float(input())
b = float(input())
t = np.linspace(-np.pi, np.pi, 201)
x = np.sin(a * t + np.pi / 2)
y = np.sin(b * t)
plot(x, y)
show()
a = 0.5, b = 1
a = 1, b = 0.5
a = 3, b = 4
a = 3, b = 10
a = 4, b = 3
a = 4, b = 10
- 简谐运动
import matplotlib.pyplot as plt
import numpy as np
def f(t):
return np.cos(2 * np.pi * t)
a = np.arange(0.0, 5.0, 0.02)
plt.plot(a, f(a))
plt.xlabel('横坐标(时间)', fontproperties='Kaiti', fontsize=14, color='red')
plt.ylabel('纵坐标(振幅)', fontproperties='SimHei', fontsize=18, color='red')
plt.title('简谐运动 y=cos(2πx)', fontproperties='SimHei', fontsize=18, color='green')
plt.grid(True)
plt.axis([-1, 6, -2, 2])
plt.annotate('简谐运动曲线', xy=(3, 1), xytext=(4, 1.5), arrowprops=dict(facecolor='black', shrink=0.2),
fontproperties='SimHei', fontsize=12, color='red')
plt.show()