pandas - 在饼图 pandas 上显示一个标签

标签 pandas dataframe graph label pie-chart

有没有办法只显示一组标签?目前看起来很乱,我想要一套标签。我做了 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

关于pandas - 在饼图 pandas 上显示一个标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44238913/

相关文章:

python - 具有多种配色方案的带注释的热图

Python计算组内数据框中唯一值的数量

python - 如何只替换子字符串而不替换整个字符串?

android - 使用 GraphView 库在 Android 中的条形图中的条之间的间距

python - 防止 matplotlib 将我的轴重新设置为零

Python pandas groupby 与按列过滤的其他行的区别

python - 如何获取包含与索引对应的特定值的列列表作为 Pandas 数据框中的新列?

r - 将多个列值粘贴到 R 中的一个值中

algorithm - 通过矩形数组路由 "paths"

r - R 基础对称矩阵中的图形可视化,其值为对角线