how do I redraw an image using python's matplotlib?

南楼画角 提交于 2019-11-30 12:46:12

You can simply call figure.canvas.draw() each time you append something new to the figure. This will refresh the plot.

from matplotlib import pyplot as plt
from builtins import input

fig = plt.figure()
ax = fig.gca()
fig.show()

block = False
for i in range(10):
    ax.plot(i, i, 'ko')
    fig.canvas.draw()
    if block: 
        input('pause : press any key ...')
    else:
        plt.pause(0.1)
plt.close(fig)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!