import matplotlib.pyplot as plt
labels='Frogs','Hogs','Dogs','Logs'
sizes=[15,30,45,10]
explode=(0,0.01,0,0)
plt.pie(sizes,explode,labels,autopct='%1.1f%%',shadow=True,startangle=90)
plt.axis('equal')
plt.show()
#条形图绘制
#教材p327
import numpy as np
import matplotlib.pyplot as plt
datearr=['2018Y','2019Y','2020Y','2021Y']
num_masks=np.asarray([45.4,50,62.2,77])
plt.bar(datearr,num_masks,width=0.3)
plt.xlabel('2018年— —2021年',fontproperties='SimHei',fontsize=10)
plt.ylabel('数量/亿只',fontproperties='SimHei',fontsize=10)
plt.title('2018年——2021年中国大陆地区口罩生产量',fontproperties='SimHei',fontsize=15)
plt.savefig('test5',dpi=600)
plt.savefig('../picture/test5',dpi=600)
plt.show()