1.代码:
import matplotlib.pyplot as plt import numpy as np plt.rcParams['font.sans-serif'] = 'simhei' plt.rcParams['axes.unicode_minus'] = False data = [40, 15, 20, 10, 15] label = ["数据1", "数据2", "数据3", "数据4", "数据5"] # 要把离心率设置远一点,怕第二个饼图挡住这个百分率 plt.pie(data, pctdistance=0.8, autopct='%.1f%%') # 所谓的环形图,就是再画一个比上个图小的饼图,并且为白色,所以半径要小 plt.pie([1], radius=0.6, colors='w') plt.legend(label, loc='upper left') plt.show()
2.效果: