以十六进制格式提取 Matplotlib 颜色图
要以十六进制格式提取matplotlib颜色图,我们可以采取以下步骤-
获取彩虹色图。
在彩虹色图长度范围内迭代。
使用rgb2hex方法,将rgba 元组转换为颜色的十六进制表示。
示例
from matplotlib import cm
import matplotlib
cmap = cm.rainbow
for i in range(cmap.N):
rgba = cmap(i)
print("Hexadecimal representation of rgba:{} is {}".format(rgba, matplotlib.colors.rgb2hex(rgba)))输出结果............... ........................ .................................... Hexadecimal representation of rgba:(1.0, 0.3954512068705424, 0.2018824091570102, 1.0) is #ff6533 Hexadecimal representation of rgba:(1.0, 0.38410574917192575, 0.1958454670071669, 1.0) is #ff6232 Hexadecimal representation of rgba:(1.0, 0.37270199199091436, 0.18980109344182594, 1.0) is #ff5f30 .........................................................
热门推荐
10 小红书平安祝福语简短
11 生日祝福语大全女孩简短
12 收生日红包祝福语 简短
13 领证幽默祝福语简短
14 法考面试祝福语简短
15 老哥出门祝福语简短语
16 送灯祝福语简短独特
17 幼儿狗年祝福语大全简短
18 好听的元旦简短祝福语