Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get hex from color name 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.

Thanks.

like image 291
Oren Avatar asked Dec 24 '22 23:12

Oren


1 Answers

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'
like image 133
Carsten Avatar answered Jan 05 '23 10:01

Carsten