简单问题:Matplotlib 绘制多条二维线
我想在 Mat-Plot-Lib 中绘制多条 2D 线,但希望将它们动画化到绘图上。 换句话说,我希望出现一行,然后是另一行,然后是另一行,依此类推...... 目前,我有以下内容:
for line in lines:
y = line
plt.plot(x,y,'-r')
plt.grid()
plt.show()
time.sleep(1)
但是,最终发生的情况是我得到了一堆不同的图,每个图都绘制了下一行。我需要所有这些线一条接一条地出现在同一张图表上。 我该怎么做?
I want to draw multiple 2D lines in Mat-Plot-Lib, but want to animate them onto a plot.
In other words, I want one line to appear, then another, then another, and so on...
Currently, I have the following:
for line in lines:
y = line
plt.plot(x,y,'-r')
plt.grid()
plt.show()
time.sleep(1)
However, what ends up happening is that I get a bunch of different plots, each plotting the next line. I need all of these lines to appear on the same graph, one after another.
How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
绘制线之后的plt.show:
plt.show after the lines are drawn: