数据:
选手 | 伤害占比 |
4AM_ZGG01 | 27% |
4AM_forever | 24% |
4AM_weless | 25% |
4AM_xlxuu | 25% |
Ifty_boliang | 24% |
Ifty_longskr | 30% |
Ifty_ilnn | 20% |
Ifty_aplusive | 26% |
import pandas as pd
import matplotlib.pyplot as plt
from pylab import *
mpl.rcParams['font.sans-serif'] = ['SimHei']
excelFile = r'C:/Users/admin/Desktop/2019.10.05/饼状图/damage.xlsx'
df=pd.DataFrame(pd.read_excel(excelFile))
fig = plt.figure()
ax1 = fig.add_subplot(1, 2, 1)
ax2 = fig.add_subplot(1, 2, 2)
x=df['伤害占比']
y=df['选手']
a=x[0:4]
b=y[0:4]
c=x[4:8]
d=y[4:8]
ax1.pie(a,labels=b,autopct='%1.2f%%') #画饼图(数据,数据对应的标签,百分数保留两位小数点)
ax2.pie(c,labels=d,autopct='%1.2f%%') #画饼图(数据,数据对应的标签,百分数保留两位小数点)
plt.show()
结果: