Python modules using matplotlib continuous display pictures

I do not know why some need to write show(), cycle time would not, seek large explained to me, in addition, how to write to cycle through multiple images when elegance

Display a simple code as follows

from matplotlib import pyplot as plt
import numpy as np
plt.imshow(np.random.randint(0, 2, (2, 2)))
plt.show()

Here Insert Picture Description
Continuous change of a map write

from matplotlib import pyplot as plt
import numpy as np
while 1:
    plt.cla()
    plt.imshow(np.random.randint(0, 2, (2, 2)))
    plt.pause(0.1)

Sometimes you need to compare the two figures together look, I wrote this code, but the big picture or the picture more than the feeling of Caton there, I think it is memory not removed, seeking guidance Gangster

from matplotlib import pyplot as plt
import numpy as np
while 1:
    plt.cla()
    ax1 = plt.subplot(1, 2, 1)
    ax1.imshow(np.random.randint(0, 2, (2, 2)))
    ax2 = plt.subplot(1, 2, 2)
    ax2.imshow(np.random.randint(0, 2, (2, 2)))
    plt.pause(0.1)
    ax1.cla()
    ax2.cla()

Here Insert Picture Description

Published 163 original articles · won praise 117 · views 210 000 +

Guess you like

Origin blog.csdn.net/u010095372/article/details/102947856