我有一个基于CSV文件创建饼图的脚本。当我读一个只有一行的CSV时,我的问题就开始了(例如percent = [100]
)。使用饼图有什么限制吗?其中只有一个项目不能100%显示?错误似乎与startangle
或explode
参数有关。在
我的代码是:
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}$谢谢!在
将
explode
参数更改为list
:如果有更多的值,则可以使用
^{pr2}$tuple
,但是对于一个值,(int)
将被视为一个整数:相关问题 更多 >
编程相关推荐