 # Colours of histograms?

Hi

how do I specify the colour of the bars in an histogram done with more than one set of data?

Example:

x1 = random(1000)
x2 = random(1000)

hist([x1,x2], c=['r','b'])

does not work...

I have tried with rgba sequences but no luck there. The help of hist
<< color: matplotlib color arg or sequence of rgba tuples >>

so I guess we can specify the individual colours of each set of bars (one colour per dataset) no?

thanks.

Eric

Based on my quick look at the code, it seems that the documentation is
incorrect. I believe it should be "a tuple of rgba values", not
"sequence of rgba tuples", and I don't think it is possible to specify
color"s" using keyword arguments.

x1 = random(1000)
x2 = random(1000)

n, bins, patches = hist(np.array([x1, x2]).transpose())

plt.setp(patches, color="r")
plt.setp(patches, color="b")

also see

http://matplotlib.sourceforge.net/examples/pylab_examples/hist_colormapped.html

Regards,

-JJ

p.s., Is it just me who think it is confusing that hist([x1,x2])
interprets input differently when len(x1) == len(x2) and when len(x1)
!= len(x2)?

···

On Wed, Dec 30, 2009 at 12:05 PM, Eric Emsellem <eemselle@...513...> wrote:

I have tried with rgba sequences but no luck there. The help of hist
<< color: matplotlib color arg or sequence of rgba tuples >>

great. Thanks! I had a look at the thumbnails but didn't find the one
you point out. (And the doc is confusing)

Thanks!

and yes, very weird behaviour when the two arrays have the same length...

Eric

···

On 30/12/09 19:53, Jae-Joon Lee wrote:

x1 = random(1000)
x2 = random(1000)

n, bins, patches = hist(np.array([x1, x2]).transpose())

plt.setp(patches, color="r")
plt.setp(patches, color="b")

also see

http://matplotlib.sourceforge.net/examples/pylab_examples/hist_colormapped.html