from matplotlib import cm
pot_values = [0, 51, 102, 153, 204, 255]
rgb = []
for x in pot_values:
val = cm.jet(float(x)/255)[:3] # The 4th element is gamma
rgb.append([round(x*255) for x in val])
print(rgb)
# Output:
# [[0.0, 0.0, 128.0],
# [0.0, 76.0, 255.0],
# [41.0, 255.0, 206.0],
# [206.0, 255.0, 41.0],
# [255.0, 104.0, 0.0],
# [128.0, 0.0, 0.0]]
使用matplotlib colormaps之一。我建议使用
jet
颜色图,因为大多数人都熟悉蓝色表示小值而红色表示大值的解释。在相关问题 更多 >
编程相关推荐