以十六进制格式提取 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 .........................................................
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP