matplotlib.pyplot 中的 HSV 颜色图

时间:2021-03-23 09:58:22

标签: python matplotlib hsv

我正在尝试重现显示 hue distribution 使用 HSV 颜色图的图像。

我有与色调通道相关的信息,表示为字典,聚合在多个样本上:

hue = {
    0 : hue_0,
    1 : hue_1,
    ...
  255 : hue_255
}

我尝试通过以下方式使用 here 中 matplotlib 的 colorline 示例:

import matplotlib.pyplot as plt

x = list(hue.keys())
y = list(hue.values())

fig, ax = plt.subplots()
lc = colorline(x, y, cmap='hsv')
plt.colorbar(lc)
plt.xlim(0, 255)
plt.ylim(0, max(y))
plt.show()

但它产生了this

我已经想出了如何将 Hue dict 绘制为一条线:

import matplotlib.pyplot as plt

lists = sorted(hue.items())

x, y = zip(*lists)

plt.plot(x, y)
plt.show()

但我不知道如何将 HSV 颜色图添加到绘图中。

0 个答案:

没有答案