我有一个matplotlib窗口,其中包含多个子图。我希望能够在调用方法时动态更新每个子图的内容。简化的代码如下:
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(1)
fig, ax_list = plt.subplots(3, 2)
image1 = plt.imread("image1.jpg")
image2 = plt.imread("image2.jpg")
ax_list = ax_list.ravel()
ax_list[0].imshow(image1)
ax_list[1].imshow(image2)
plt.show()
def update_subplots():
# I want this method to change the contents of the subplots whenever it is called
pass
ax_list[0].cla(); ax_list[0].imshow(image2)
,等等? - tmdavisondef update_subplot(subplot):
- gboffi