this question 的答案说明如何通过 RGB 元组指定散点图标记颜色。
颜色网格是否有可能类似的东西,其中每个 x,y 对的颜色由 RGB 元组而不是颜色图值给出?
最佳答案
我不确定 pcolormesh
是否可以轻松用于创建 rgb 图像(我自己对这个问题的答案很感兴趣)。但是,使用 imshow
或 axes_grid1.axes_rgb
创建 rgb 图像相对容易。总结比较全面的教程here和 here :
import numpy as np
import pylab as plt
from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes
rgb = np.random.random((5, 5, 3))
fig = plt.figure()
ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8])
ax.imshow_rgb(rgb[:,:,0],rgb[:,:,1],rgb[:,:,2],interpolation='none')
plt.figure()
plt.imshow(rgb,interpolation='none')
生成的图像如下所示:
关于python - 使用 RGB 元组的 Matplotlib pcolormesh,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32031078/