以十六进制格式提取 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 送给学长毕业祝福语简短