#分析苹果2020Q2季度与2019Q2季度出货量可视化图
matplotlib中饼状图,一张布中放置两张图
下面展示一些 代码
#饼图
import matplotlib.pyplot as plt
labels = '苹果', '华为','微软','联想','其他'
sizes1 = [276, 245, 23, 17,99,]
sizes2=[233,154,20,22,133]
explode = (0.5, 0.3, 0, 0.1,0.1) # only "explode" the 2nd slice (i.e. 'Hogs')
fig,axes=plt.subplots(1,2)
# ax1.pie(sizes1, explode=explode, labels=labels, autopct='%1.1f%%',
# shadow=True, startangle=90)
# ax2.pie(sizes2, explode=explode, labels=labels, autopct='%1.1f%%',
# shadow=True, startangle=90)
# ax2.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
axes[0].pie(sizes1,
labels=labels,
explode=explode,
autopct='%.2f%%',#数值设置为保留固定小数位的百分数
shadow=True,#无阴影设置
startangle=90,#逆时针起始角度设置
)#在axes[0]上
axes[0].axis('equal')#x,y轴刻度一致,保证饼图为圆形
axes[0].legend(loc='best')
axes[0].set_title('2020Q2中国平板厂商出货量(单位:万台) ')
axes[1].pie(sizes2,
labels=labels,
explode=explode,
autopct='%.2f%%',#数值设置为保留固定小数位的百分数
shadow=False,#无阴影设置
startangle=180,#逆时针起始角度设置
)#在axes[1]
axes[1].axis('equal')#x,y轴刻度一致,保证饼图为圆形
axes[1].set_title(' 2019Q2中国平板厂商出货量(单位:万台)')
# axes[1].legend(loc='best')
fig.savefig('apple.jpg',dpi=600)
效果图