plt.show() 不显示任何内容

时间:2021-03-07 20:56:14

标签: python matplotlib spyder

我不明白为什么 plt.show() 什么都不显示

import matplotlib.pyplot as plt

plt.figure()
plt.imshow(image_np_with_detections)
plt.show()

我使用了 plt.imsave("test2.png",image_np_with_detections),它确实使用了 plt.show()

保存了我想在屏幕上显示的图片

我已经看到了 this answer which does not solve my issue,因为我只使用了一次 plt.show()

我错过了什么?

1 个答案:

答案 0 :(得分:0)

尝试使用 plt.imread 而不是 plt.imsave。这对我有用

img = plt.imread(r"C:\temp\image.png")
plt.imshow(img)