1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
plt.pie(x=data.values, labels=data.index, \
colors=['c', 'springgreen', 'salmon'], autopct='%.0f%%', \
pctdistance=0.82, labeldistance=1.1,\
startangle=120, radius=1.2, counterclock=False, \
wedgeprops={'linewidth': 1.5, 'edgecolor': 'green'}, \
textprops={'fontsize': 14, 'color': 'black'})
# 中间部分
plt.pie(x=[1], colors='white', radius=0.8, \
wedgeprops={'linewidth': 1.5, 'edgecolor': 'green'})
# 总量标记
plt.text(0,0, data.values.sum(), fontsize=16, va='center', ha='center')
plt.title('电影类型环形图', pad=20, fontsize=16)
plt.savefig('img/hw22.png')
plt.show()
|