Untitled
unknown
python
2 years ago
933 B
5
Indexable
a = 1 fig = plt.subplots(figsize =(15, 5)) T_tau = [2, 4, 16] X = np.arange(-20, 20, dtype=np.int32) Y_1 = np.array([a*T_tau[0]/((math.pi * n)**2)*(1-math.cos(math.pi*n/T_tau[0])) if n != 0 else a/(2*T_tau[0]) for n in X], dtype=float) Y_2 = np.array([a*T_tau[1]/((math.pi * n)**2)*(1-math.cos(math.pi*n/T_tau[1])) if n != 0 else a/(2*T_tau[1]) for n in X], dtype=float) Y_3 = np.array([a*T_tau[2]/((math.pi * n)**2)*(1-math.cos(math.pi*n/T_tau[2])) if n != 0 else a/(2*T_tau[2]) for n in X], dtype=float) plt.vlines(X, ymin=0, ymax=Y_1, color='green', alpha=0.7, linewidth=8) plt.vlines(X, ymin=0, ymax=Y_2, color='orange', alpha=0.7, linewidth=5) plt.vlines(X, ymin=0, ymax=Y_3, color='red', alpha=0.7, linewidth=2) plt.scatter(X, Y_1, color='green', s=40, label="τ = T/2") plt.scatter(X, Y_2, color='orange', s=25, label="τ = T/4") plt.scatter(X, Y_3, color='red', s=10, label="τ = T/16") plt.grid() plt.legend()
Editor is loading...