从颜色名称matplotlib获取十六进制 [英] get hex from color name matplotlib
本文介绍了从颜色名称matplotlib获取十六进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道matplotlib支持的颜色列表:
I know this list of colors that matplotlib support:
https://pythonhosted.org/ete2/reference/reference_svgcolors.html
是否存在以编程方式将此名称转换为十六进制的方式?
Is there a programmatic way to convert this names to hex ?
我想要一个接收颜色名称并返回该颜色十六进制值的函数。
I would like a function that receive the color name and return the hex value of this color.
谢谢。
推荐答案
matplotlib.colors.cnames
是所有字典matplotlib的颜色及其十六进制值:
matplotlib.colors.cnames
is a dictionary of all of matplotlib's colors and their hex values:
import matplotlib
print matplotlib.colors.cnames["blue"]
--> u'#0000FF'
这篇关于从颜色名称matplotlib获取十六进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文