

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Code for pie chart using python
Typology: Lab Reports
Uploaded on 10/21/2023
1 document
1 / 2
This page cannot be seen from the preview
Don't miss anything!
[1]: import pandas as pd
data = pd.read_csv (r'eg01-02majors.csv') print(data)
Field of Study Percent 0 ArtsHumanities 8. 1 BiologicalSciences 15. 2 Business 13. 3 Education 4. 4 Engineering 11. 5 HealthProf 11. 6 MathComp 6. 7 PhysicalSciences 2. 8 Social Sciences 11. 9 Other 13.
[2]: df = pd.DataFrame(data, columns = ['Field of Study', 'Percent']) df
[2]: Field of Study Percent 0 ArtsHumanities 8. 1 BiologicalSciences 15. 2 Business 13. 3 Education 4. 4 Engineering 11. 5 HealthProf 11. 6 MathComp 6. 7 PhysicalSciences 2. 8 Social Sciences 11. 9 Other 13.
[3]: import matplotlib.pyplot as plt fig = df.plot.pie(y='Percent', figsize=(5,5), labels=df['Field of Study'],legend= False , title="Percent of Students",label='') plt.show(fig)
[4]: #saving the figure as a pdf file fig.figure.savefig('piechart.pdf')
[ ]: