【问题标题】:Showing one label on pie chart pandas在饼图 pandas 上显示一个标签
【发布时间】:2017-05-29 09:22:18
【问题描述】:

有没有办法只显示一组标签?目前它看起来很乱,我想要一套标签。我做了label=None,它关闭了所有标签。

谢谢

【问题讨论】:

    标签: pandas dataframe graph label pie-chart


    【解决方案1】:

    我觉得你需要一点改变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()
    

    【讨论】:

      猜你喜欢
      • 2017-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-21
      • 2017-08-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多