admin管理员组文章数量:1133926
I am trying to translate the following MATLAB code to Python. In MATLAB, the code dynamically updates a single plot for multiple iterations (n = 1:100), and each update displays the interpolation alongside the original function.
for n = 1:100
[err, t, f, x, p] = intlag(n);
plot(x, sin(x), '-r', x, p, '-b'); % 1./(5*x.*x+1)
axis([-1 1 -2 2])
legend('fonction', 'interpolant')
title(['t = ', num2str(n)])
drawnow
end
I attempted to use matplotlib with plt.ion()
and plt.pause()
, but I couldn't achieve the same smooth dynamic updates. Also, I want to ensure that all updates occur in a single figure.
Can someone help me write a Python equivalent for this functionality?
本文标签:
版权声明:本文标题:numpy - How to dynamically update a single plot for multiple iterations in Python (equivalent to MATLAB drawnow)? - Stack Overfl 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736776447a1952366.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论