import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']
# 每一块占的比例,总和为100
mm = [3708, 3213, 3079]
n = mm[0] + mm[1] + mm[2]
a = (mm[0] * 1.0 * 100/n)
b = (mm[1] * 1.0 * 100/n)
c = (mm[2] * 1.0 * 100/n)
print(a, b, c, n)
fracs = [a, b, c]
explode = (0, 0, 0) # 离开整体的距离
labels = '时间', '成本', '可靠性'
plt.pie(fracs, explode=explode, labels=labels, autopct='%1.3f',
shadow=True, startangle=90, colors=("c", "brown", "orange"))
plt.show()
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.figure(figsize=(9,6))
labels = [u'时间',u'成本',u'可靠性']
sizes = [3708, 3213, 3079]
colors = ['c','yellowgreen','lightskyblue']
patches,l_text,p_text = plt.pie(sizes,labels=labels,colors=colors,
labeldistance = 1.1,autopct = '%3.2f%%',shadow = False,
startangle = 90,pctdistance = 0.6)
for t in l_text:
t.set_size(25)
for t in p_text:
t.set_size(25)
plt.gca()
plt.legend()
plt.show()