【发布时间】:2016-09-14 11:21:01
【问题描述】:
我有一个基于 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 行出错:
if len(x) != len(explode):
TypeError: object of type 'float' has no len()
谢谢!
【问题讨论】:
标签: python matplotlib charts