Matplotlib only defines below basic colors:
•b: blue
•g: green
•r: red
•c: cyan
•m: magenta
•y: yellow
•k: black
•w: white
And I want to define more custom color letters, such as
mc1 = RGB(164,106,228)
mc2 = RGB(220,170,114)
mc3 = RGB(249,85,132)
then I can define
my_color_list = ['g','r','y','b','c','m','k', 'mc1','mc2','mc3']
Then my_color_list can be use for below demo:
import matplotlib.pyplot as plt
dt = [1,2,3,4,5,6,7,8,9]
my_color_list = ['g','r','y','b','c','m','k', 'mc1','mc2','mc3'] # not valid
bar(range(len(dt)),dt,color=my_color_list)
plt.show()
So how to define customize color letter in matplotlib ? Or, if I have a list of RGB tuple, how to combine RGB tuple together with basic color letters and assign to ‘color’ parameter of ‘plot’/’bar’ command ?
matplotlib supports many ways to specify the color. In addition to the basic colors, you can use CSS color hex codes, Web color names and RGB values.
'#d2691e'.'chocolate'.(0.824, 0.412, 0.118). The components should be normalized to fall within [0, 1].'0.7'.Whenever a color is expected, these forms can be used just like the standard one-letter color names.
See: http://matplotlib.org/api/colors_api.html