1
我想繪製一個包含三個不同圖形的繪圖。這是我的代碼:圖形不會顯示何時縮放軸
import numpy as np
from math import sqrt
import matplotlib.pyplot as plt
def make_sequence(N:int, alpha:float, beta:float) -> np.ndarray:
z_n = np.empty((N, 1))
for n in range(1, N+1):
z_n[n-1] = alpha*(1+sqrt(3))**n + beta*(1-sqrt(3))**n
return z_n
x0 = make_sequence(50, 0.0, 1.0)
x1 = make_sequence(50, 0.0, 99.0)
x2 = make_sequence(50, 5.0, 5.0)
plt.plot(x0, 'bo')
plt.plot(x1, 'ro')
plt.plot(x2, 'go')
plt.axis([0, 50, -2, 2])
plt.title(r'$z_1,...,z_{50}$')
plt.xlabel('n')
plt.legend([r'$\alpha =0$, $\beta =1$', r'$\alpha =0$, $\beta =99$', r'$\alpha =5$, $\beta =5$'])
plt.show()
爲什麼x2不顯示在圖上?
如果我嘗試單獨繪製x2,它只會顯示如果我刪除軸縮放命令。