-2
CSVファイルに基づいて円グラフを作成するスクリプトがあります。私の問題は、行が1つしかないCSV(たとえばpercent = [100]
)を読んでから始まりました。円グラフを使用する場合、1つのアイテムに対して100%表示されない点がありますか?このエラーは、startangle
またはexplode
引数のいずれかと関連しているようです。円グラフの問題matplotlib - startangle/len()
私のコードは次のとおりです。
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()
ありがとう!
あなたが解決私の問題。ありがとう! – Gonzalo