Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I create for each category a horizontal bar plot that consists of shares

I have the following df

    type    eur_d   asia_d  amer_d
0   cat1    0.58    0.30    0.12
1   cat2    0.50    0.29    0.21
2   cat3    0.50    0.30    0.20
3   cat4    0.42    0.31    0.27
4   cat5    0.42    0.37    0.20
5   cat6    0.60    0.21    0.19
6   cat7    0.26    0.50    0.24
7   cat8    0.54    0.17    0.30
8   cat9    0.46    0.25    0.29

Ideally I want to create 9 horizontal bar of same length that shows the share of Europe, Asia, and America for each category with different colors.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you mean stacked horizontal bar chart, this can help.

df.plot.barh(x="type", stacked=True, figsize=(10, 5))
plt.show()

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading