这只提供一种颜色:import matplotlib.pyplot as plt
plt.imshow([[(0, 0, 1)]])
^{pr2}$
您需要MxNx3的形状:>>> import numpy as np
>>> np.array([[(0.5, 0.5, 0.5)]]).shape
(1, 1, 3)
这里M和N是1。在plt.imshow(X, ...)
X : array_like, shape (n, m) or (n, m, 3) or (n, m, 4)
Display the image in X to current axes. X may be a float
array, a uint8 array or a PIL image. If X is an array, it
can have the following shapes:MxN luminance (grayscale, float array only)
MxNx3 RGB (float or uint8 array)
MxNx4 RGBA (float or uint8 array)
The value for each component of MxNx3 and MxNx4 float arrays
should be in the range 0.0 to 1.0; MxN float arrays may be
normalised.
您需要在0和1之间转换int float:from __future__ import division # need for Python 2 only
plt.imshow([[(100 / 255, 100 / 255, 200 / 255)]])