阅读背景:

豆瓣TOP250_forget_00的博客

来源:互联网 

####绘制饼图

from random import randint
from matplotlib import pyplot as plt
plt.rcParams["font.sans-serif"] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
# x是饼图中各个元素的值
x = [randint(3000, 15000) for _ in range(8)]
# 每个元素的标签
labels = ['员工{}'.format(i) for i in range(1, 9)]
colors = ['red', 'blue', 'green', 'yellow','pink','purple','gray','orange']
# 每一个元素距离中心点的距离 可选值 0~1
explode = [0, 0, 0, 0, 0, 0, 0, 0.2]
plt.pie(x=x,
        labels=labels,
        colors=colors,
        shadow=True,
        startangle=90,#开始的角度
        explode=explode,
        autopct='%1.1f%%' # 显示百分比
        )
plt.axis('equal') # 设置成标准圆形
plt.legend(loc=3)# 指定为 2象限
plt.title('某大型公司员工工资占比')
plt.show()

from random import randint
fr



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: