饼图:

 

import matplotlib.pyplot as plt

x=[9,10,2,3]
y=['sleeping','working','sporting','else']
cols=['b','r','y','g']

 

plt.pie(x,labels=y,colors=cols,
        startangle=90,                            #从90度的地方开始画。
        shadow=True,                             #为false表示二维饼图,true表示为三维饼图
        explode=(0,0.05,0,0)                  #共有4个部分,想让哪一部分突出来就写一个非零值。数值越大突出来的越多。

        autopct='%1.1f%%'                    #显示出百分比

        )

plt.title('a pie')
plt.legend()

plt.show()

运行结果:

                    Matplotlib(6)——饼图

此处为椭圆形饼图,若想要圆形可以增加语句: plt.axis(‘equal’)

 

 

 

 

 

 

 

 

 

 

 

相关文章:

  • 2021-08-29
  • 2021-06-27
  • 2021-06-16
  • 2021-11-20
  • 2022-01-27
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-20
  • 2021-04-04
  • 2022-03-03
  • 2021-09-25
  • 2021-04-18
  • 2021-08-07
  • 2021-10-17
相关资源
相似解决方案