2016-09-29 33 views
1

我想繪製這個函數:f(x)= e^-x/10 sin(πx) 我試過用這段代碼,但是我沒有得到連貫的圖。如何繪製特定功能?

t=np.linspace(0,10) 
curve1 =np.exp(-t/10)*np.sin(t*np.pi) 
plt.plot(t,curve1) 

回答

1

你必須調用show()你打電話plot()後實際查看圖。以下是基於工作代碼斷你的代碼:

from matplotlib.pyplot import plot, show 

t=np.linspace(0,10) 
curve1 =np.exp(-t/10)*np.sin(t*np.pi) 
plot(t,curve1) 
show() 

輸出:

enter image description here

0

你什麼意思,你沒有得到一個連貫的曲線?這段代碼適用於我,也許你需要使用plt.show()?

t=np.linspace(0,10) 
curve1 =np.exp(-t/10)*np.sin(t*np.pi) 
plt.plot(t,curve1) 
plt.show()