KnowledgeBoat Logo
|

Informatics Practices

Write suitable Python code to create 'Favourite Hobby' Bar Chart as shown below :

Write suitable Python code to create 'Favourite Hobby' Bar Chart as shown below : Informatics Practices Computer Science Sumita Arora Solutions CBSE Class 12

Also give suitable python statement to save this chart.

PyPlot

8 Likes

Answer

import matplotlib.pyplot as plt
hobbies = ['Dance', 'Music', 'Painting', 'Playing Sports']
people_count = [300, 400, 100, 500]
plt.bar(hobbies, people_count)
plt.xlabel('Hobbies')
plt.ylabel('Number of People')
plt.title('Favourite Hobby')
plt.savefig('favourite_hobby_chart.png')
plt.show()
Output
Write suitable Python code to create 'Favourite Hobby' Bar Chart as shown below : Plotting with Pyplot, Informatics Practices Computer Science Sumita Arora Solutions CBSE Class 12

Answered By

5 Likes


Related Questions