I started working with the Matplotlib pie chart and looks good so far! I am having only a few issue.
I am interested in a particular column and they are kind of categorical but numbers and these numbers mean different kinds of stuff that I would like to depict on the pie chart.
Here is my working code. I started off with a Python dictionary to map out the numbers
valuelables = {
1:"Deutschland",
2:"UK",
3:"America"
}
s1 = df.request.value_counts(normalize=True)*100
size = s1.tolist()
keys = s1.keys().tolist()
In order for you to produce on your local computer:
print(size) # size gives a list [99.22871437721278, 0.5294334011693548, 0.2418522216178678]
print(keys) # keys give [2, 1, 3]
patches, texts = plt.pie(size, shadow=True, startangle=90, autopct='%1.1f%%')
plt.legend(patches, valuelables[keys], loc="best")
plt.axis('equal')
Unfortunately, I get the following error: TypeError: unhashable type: 'list'
This obviously comes from the dictionary mapping in the plt.legend(). How do I map it to produce a new pie plot like this below with the values on the plot like the second plot: