Reputation: 101
I have been able to change the facecolor of a plot using basic colors, r,g,b etc. However, I am working on a project and I need to prepare a presentation that will be visually pleasing and I would like to use a wider range of colors, such as colors that are listed here. This is the code I am using (I want the area below the graph to be colored):
fig = plt.figure(num=None, figsize=(30, 50))
ax1 = fig.add_subplot(2,1,1)
ax1.plot(x, y, 'k-')
ax1.fill_between(x, min(y), y, facecolor='#8B0000')
However, facecolor does nothing when I use HEX colors, but it works when I use 'r','b' etc. Is there any way to use HEX color codes for fill_between?
Upvotes: 1
Views: 3688
Reputation: 2230
According the docs facecolor
accepts matplotlib color arg or sequence of rgba tuples. If you want to use hex colors you must first convert the hex value to correct format. Take a look at the matplotlib.colors
module. I'm not fully familiar with the library but maybe hex2color is of use.
Upvotes: 2