如何在“ while”中绘制一条线python中的循环?

发布于 2025-02-04 12:09:54 字数 333 浏览 1 评论 0原文

尝试使用matplotlib在“ while”循环中绘制线路。 这显示了一个空白的图:

plt.plot(t, cash)
plt.xlim([t_start, t_end])
plt.ylim([c_min,c_max])
plt.pause(0.1)

然后使用:

plt.plot(t, cash,'r.')
plt.xlim([t_start, t_end])
plt.ylim([c_min,c_max])
plt.pause(0.1)

如预期的那样,显示了随行循环更新的红点。 如何用一条线得到这个情节? 谢谢 !

Trying to plot a line inside a "while" loop using matplotlib.
This shows a blank figure:

plt.plot(t, cash)
plt.xlim([t_start, t_end])
plt.ylim([c_min,c_max])
plt.pause(0.1)

then using:

plt.plot(t, cash,'r.')
plt.xlim([t_start, t_end])
plt.ylim([c_min,c_max])
plt.pause(0.1)

shows red dots being updated with the while loop, as expected.
How to get this plot with a line?
Thank You !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

机场等船 2025-02-11 12:09:54

我不确定我是否理解这个问题,但听起来您只是想用线路绘制点?

plt.plot(t, cash,'r-')

I am not sure if I understand the problem, but it sounds like you simply want to exchange the dot with a line plot?

plt.plot(t, cash,'r-')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文