How to update matplotlib's imshow() window interactively?

后端 未结 4 1537
孤独总比滥情好
孤独总比滥情好 2020-11-30 05:19

I\'m working on some computer vision algorithm and I\'d like to show how a numpy array changes in each step.

What works now is that if I have a simple imshow(

4条回答
  •  感情败类
    2020-11-30 06:14

    If you are using Jupyter, maybe this answer interests you. I read in this site that the emmbebed function of clear_output can make the trick:

    %matplotlib inline
    from matplotlib import pyplot as plt
    from IPython.display import clear_output
    
    plt.figure()
    for i in range(len(list_of_frames)):
        plt.imshow(list_of_frames[i])
        plt.title('Frame %d' % i)
        plt.show()
        clear_output(wait=True)
    

    It is true that this method is quite slow, but it can be used for testing purposes.

提交回复
热议问题