Change colours of Pandas bar chart

后端 未结 2 589
旧巷少年郎
旧巷少年郎 2021-01-03 05:43

I want the bars in a Pandas chart to each be given a different colour. The solution looks pretty simple according to this post and ones like it.

When I try to emulat

2条回答
  •  时光取名叫无心
    2021-01-03 05:53

    Let's use this code instead:

    df.plot(kind='bar',    # Plot a bar chart
            legend=False,    # Turn the Legend off
            width=0.75,      # Set bar width as 75% of space available
            figsize=(8,5.8),  # Set size of plot in inches
            color=[plt.cm.Paired(np.arange(len(df)))])
    

提交回复
热议问题