gpt4 book ai didi

python - Pandas 条形图

转载 作者:太空宇宙 更新时间:2023-11-03 14:04:20 29 4
gpt4 key购买 nike

我刚刚转移到 pandas 0.20/matplotlib 2.0 python 3.6。 (共构成以下版本)。我用 pandas 来绘制条形图,因为 matplotlib 的级别总是太低。着色列的行为现在已经改变,我不知道如何解决这个问题。它曾经是以下内容:

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)

制作:

Old Version

但现在图表产生:

New Version

因此第一种颜色被拾取而不是其余颜色。

想知道这是错误还是新方法,但我找不到正确的引用。

最佳答案

将颜色作为列表传递:

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

关于python - Pandas 条形图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45283494/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com