【发布时间】:2020-02-19 03:58:47
【问题描述】:
这是一个简单的可重现代码:
import numpy as np
import matplotlib.pyplot as plt
plt.figure()
img = np.ones((3,3))
plt.imshow(img)
plt.figure()
plt.imshow(np.array([1,1,1,1,0,1,1,1,1]).reshape(3,3))
它会给你如下图:
即使你使用
plt.imshow(img.astype(float)) or
plt.imshow(img*255)
它仍然是相同的图像。
我只需要 Matplotlib 将第一张图像作为黄色图像给我,就像第二张图像一样。
【问题讨论】:
标签: python matplotlib imshow