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

Viewed 352

I wanted to show multiple images in a single cell of google colab using maltplotlib imshow()

When it is used only once in a cell, the image will be shown.

But when multiple imshow() fcalls are made , the previous imshow()s outputs are cleared .

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)

here only sus_face is shown & wkwk image is not

is there any way to see both images?

2 Answers

Simply add plt.show() after each of your plt.imshow(image)

You can also do it with subplots like this:

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