构建一个显示的数值的函数,将plt.pie中的autopct=该函数即可。...# matplotlib设置全局字体
# 创建两组数据
x1 = [30,25, 66, 13, 23]
x2 = [29, 28, 90, 19, 31]
x_0 = [1,0,0,0] #用于显示空心...my_autopct(pct):
total = sum(values)
val = int(round(pct*total/100.0))
# 同时显示数值和占比的饼图...的位置和字体
ax.legend(labels, bbox_to_anchor=(1.3,1.0), loc='center left', prop=font1)
fig.savefig('~/test.png...="equal")
plt.show()
生成图:
?