Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandas Bar Chart

I have just moved to pandas 0.20 / matplotlib 2.0 python 3.6. (form the version below in all). I've used pandas to plot bar charts because matplotlib was always too low level. The behaviour of colouring columns has now changed and I don't know how to fix that. It used to be the following:

np.random.seed(42)
d = pd.Series(data=np.random.rand(10), index=range(10))
color=np.random.rand(10,4)

d.plot.bar(color=color)

producing:

Old Version

But now the chart produces:

New Version

So that the first color is picked up but not the rest.

Wondering if it's a bug or a new methodology, though I can't find a correct reference.

like image 999
Tanguy Bretagne Avatar asked Dec 08 '25 13:12

Tanguy Bretagne


1 Answers

Pass color as a list:

np.random.seed(42)
d = pd.Series(data=np.random.rand(10), index=range(10))
color=np.random.rand(10,4)

d.plot.bar(color=[color])

enter image description here

like image 167
Scott Boston Avatar answered Dec 11 '25 01:12

Scott Boston



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!