【问题标题】:Pandas Bar Chart熊猫条形图
【发布时间】:2017-12-30 05:03:47
【问题描述】:

我刚刚迁移到 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)

制作:

但现在图表生成:

这样第一种颜色会被拾取,而不是其余的。

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

【问题讨论】:

    标签: python python-3.x pandas matplotlib


    【解决方案1】:

    将颜色作为列表传递:

    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])
    

    【讨论】:

    猜你喜欢
    • 2013-10-11
    • 1970-01-01
    • 1970-01-01
    • 2019-04-17
    • 1970-01-01
    • 2020-10-22
    • 2021-06-16
    • 1970-01-01
    相关资源
    最近更新 更多