Oren
Oren

Reputation: 5359

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.

Upvotes: 4

Views: 6092

Answers (1)

Carsten
Carsten

Reputation: 18446

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'

Upvotes: 13

Related Questions