matplotlib.pyplot中的HSV颜色图

2024-10-03 02:37:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图复制一个图表,显示 ^使用HSV颜色映射的图像的{a1}

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

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

我已经想出了如何将色调dict绘制成一条线:

import matplotlib.pyplot as plt

lists = sorted(hue.items())

x, y = zip(*lists)

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

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


Tags: importmatplotlibasshow图表plt色调hsv