import matplotlib.pyplot as plt
partition = 'holidays','eating_out','shopping','groceries'
sizes = [250,100,300,4000]
fig1,ax1 = plt.subplots() #plt.subplots()函数返回图形和坐标,分别赋值给fig1和ax1,fig = plt.figure() ax = fig.add_subplot()
'''sizes表示数据,labels表示饼图标签,autopct='%1.1f%%'表示百分比保留1位小数,startangle=90表示从y轴逆时针开始旋转'''
ax1.pie(sizes,labels=partition,autopct='%1.1f%%',shadow = True,startangle = 90)
ax1.axis('equal') #使X和Y上的轴间距相等
plt.show()