Pandas stacked bar chart duplicates colors for large legends

前端 未结 1 472
孤街浪徒
孤街浪徒 2020-12-30 16:34

I need to create a stacked bar chart with a large number (10 or so) categories. The problem is that Pandas only provides colors for up to 7 different categories. It sets the

1条回答
  •  [愿得一人]
    2020-12-30 17:38

    In [22]: colors = plt.cm.GnBu(np.linspace(0, 1, 10))
    
    In [23]: df.plot(kind='bar', stacked=True, figsize=(20, 10), color=colors)
    Out[23]: 
    

    enter image description here

    matplotlib has a bunch of different colormaps to choose from. Just don't use jet.

    0 讨论(0)
提交回复
热议问题