Python Forum
Help with pie chart in Jupyter notebook - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Help with pie chart in Jupyter notebook (/thread-28741.html)



Help with pie chart in Jupyter notebook - Rony28 - Aug-01-2020

Hi All,

I can't find a button where I can upload pictures? There is one where I can put a link, but I don't have a link.

I'll have to try to explain it.

ns is my table of patients. I am trying to do some analysis on Gender and whether they showed up or not:

I am grouping as follows:

ns_gender = ns.groupby(['Gender','No_show']).count()['Age']
I am taking the "Age" column as an arbitrary column to retrieve the counts. However this poses a problem further on.

Now I get propotional values:
mal_prop = ns_gender['M'] / gender_tots['M']
fem_prop = ns_gender['F'] / gender_tots['F']
Now I plot pie charts:

mal_prop.plot.pie(subplots = True, figsize=(5, 5),autopct='%1.1f%%'), 
fem_prop.plot.pie(subplots = True, figsize=(5, 5),autopct='%1.1f%%')
I have two issues:

1) The pie charts now have a y = "Age" from before. I cannot change it to Male/Femal even if I put y = 'Male' in the code. How do I force the label?

2) My two pie charts overlap each other. Is there a way to move one of the pie charts to the right?

Thanks in advance. Sorry I have just started learning coding and am an absolute beginner!