问题与饼图matplotlib - startangle / len()

2024-09-28 17:16:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个基于CSV文件创建饼图的脚本。当我读一个只有一行的CSV时,我的问题就开始了(例如percent = [100])。使用饼图有什么限制吗?其中只有一个项目不能100%显示?错误似乎与startangleexplode参数有关。在

我的代码是:

percent = [100]

plt.pie(percent,        # data
    explode=(0),        # offset parameters 
    #labels=country,    # slice labels - removed to hid labels and added labels=country in legend()
    colors=colors,      # array of colours
    autopct='%1.0f%%',  # print the values inside the wedges - add % to the values 
    shadow=False,       # enable shadow
    startangle=70       # starting angle
)

plt.axis('equal')
plt.legend(loc='best', labels=country) 
plt.tight_layout()

startangle=70行出错:

^{pr2}$

谢谢!在


Tags: csvtheto项目脚本labelspltcountry