How can I generate more colors on pie chart matplotlib

前端 未结 3 2106
情歌与酒
情歌与酒 2021-02-13 19:41

I am having more then 40 items to show in my chart. I have only 10 colours that repeatedly are shown on the chart. How can I generate more colors.

plt.pie(f,la         


        
3条回答
  •  星月不相逢
    2021-02-13 20:20

    I hope this answer would be useful. Check this link , Matplotlib supported colors. You can randomly pick 40 colors from it and use in your pie chart.

    mcolors.TABLEAU_COLORS
    mcolors.BASE_COLORS
    mcolors.CSS4_COLORS
    

    Sample

    import random
    import matplotlib.colors as mcolors
    colors = random.choices(list(mcolors.CSS4_COLORS.values()),k = number_of_colors)
    

提交回复
热议问题