构建一个显示的数值的函数,将plt.pie中的autopct=该函数即可。...代码:
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams['font.size...'] = 7.0 # 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.set(aspect="equal")
plt.show()
生成图:
?