I am having trouble controlling the color and linestyle of histogram plotted using Matplotlib's hist
function with stacked=True
. For a single non-stacked histogram, I have no trouble:
import pylab as P mu, sigma = 200, 25 x0 = mu + sigma*P.randn(10000) n, bins, patches = P.hist( x0, 20, histtype='stepfilled', facecolor='lightblue' )
However, when I introduce additional histograms,
import pylab as P mu, sigma = 200, 25 x0 = mu + sigma*P.randn(10000) x1 = mu + sigma*P.randn(7000) x2 = mu + sigma*P.randn(3000) n, bins, patches = P.hist( [x0,x1,x2], 20, histtype='stepfilled', stacked=True, facecolor=['lightblue','lightgreen','crimson'] )
it throws the following error:
ValueError: to_rgba: Invalid rgba arg "['lightblue', 'lightgreen', 'crimson']" could not convert string to float: lightblue
Using the color=['lightblue', 'lightgreen', 'crimson']
option does work, but I would like to have direct control of the fill and line colors separately while being able to use the named Matplotlib colors. I am using version 1.2.1 of Matplotlib.