在饼图熊猫上显示一个标签

在饼图熊猫上显示一个标签

问题描述:

有没有一种方法只显示一组标签?目前它看起来非常混乱,我希望有一套标签。我做了label=None并关闭了所有的标签。 enter image description here在饼图熊猫上显示一个标签

感谢

我认为你需要一点变化How to make MxN piechart plots with one legend and removed y-axis titles in Matplotlib

df = pd.DataFrame({'beer':[1,2,3], 
        'spirit':[4,5,6], 
        'wine':[7,8,9]}, index=['Africa','Asia','Europe']) 

print (df) 
     beer spirit wine 
Africa  1  4  7 
Asia  2  5  8 
Europe  3  6  9 

fig, axes = plt.subplots(1,3, figsize=(10,3)) 
for ax, idx in zip(axes, df.index): 
    ax.pie(df.loc[idx], labels=df.columns, autopct='%.2f') 
    ax.set(ylabel='', title=idx, aspect='equal') 

axes[0].legend(bbox_to_anchor=(0, 0.5)) 
plt.show() 

graph