python - 如何绘制特定的函数?

标签 python

我想绘制这个函数的图形: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()

输出:

enter image description here

关于python - 如何绘制特定的函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39760132/

相关文章:

python - 用 FFmpeg 录制视频会得到 "The filename, directory name, or volume label syntax is incorrect."

python - 如何在AWS lambda (python)中上传zip文件夹而不存储在S3中

python - PyCharm 2019.2 未显示异常回溯

python - 如何替换已保存图形的输入,例如数据集迭代器的占位符?

python - 在给定的翻转次数中找到特定数量的正面和反面的所有组合

python - 如何从 Python 中的数据框列元素创建字符串?

python - 将一台设备上的计算时间转换到另一台设备上的正确方法是什么?

python - 如何在 Windows 上安装 PyCairo(Python 的 Cairo)?

Python:生成二维点/簇

python - 系统错误: 10054 An existing connection was forcibly closed by the remote host in python