在单个单元格中多次调用 matplotlib imshow() 时如何保留以前的图像 google colab?

how to keep the previous images when calling matplotlib imshow() multiple times in a single cell google colab?

我想使用 maltplotlib imshow()

在 google colab 的单个单元格中显示多个图像

当在一个单元格中只使用一次时,将显示图像。

但是当进行多次 imshow() fcalls 时,先前的 imshow() 输出将被清除。

wkwk=test("face18.jpg")
#jst for face
face_locations = face_recognition.face_locations(image)
top, right, bottom, left =face_locations[0]
sus_face = image[top:bottom, left:right]

plt.imshow(wkwk)
plt.imshow(sus_face)

此处仅显示 sus_face,未显示 wkwk 图片

有什么办法可以同时看到这两张图片吗?

只需在您的每个 plt.imshow(image)

之后添加 plt.show()

你也可以像这样用子图来做:

plt.subplot(121), plt.imshow(name_of_var)
plt.subplot(122), plt.imshow(another_var)