SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Eric E. <eem...@es...> - 2009年12月30日 17:05:14
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
From: Jae-Joon L. <lee...@gm...> - 2009年12月30日 18:53:51
On Wed, Dec 30, 2009 at 12:05 PM, Eric Emsellem <eem...@es...> wrote:
> I have tried with rgba sequences but no luck there. The help of hist
> << color: matplotlib color arg or sequence of rgba tuples >>
>
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[0], color="r")
plt.setp(patches[1], 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)?
From: Eric E. <eem...@es...> - 2009年12月30日 23:02:12
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[0], color="r")
> plt.setp(patches[1], color="b")
> 
> also see
> 
> http://matplotlib.sourceforge.net/examples/pylab_examples/hist_colormapped.html
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /