我想绘制这个函数的图形: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)
最佳答案
在调用 plot()
后,您必须调用 show()
才能实际查看图表。以下是基于您的代码的工作代码:
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()
输出:
关于python - 如何绘制特定的函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39760132/