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

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

Answered By
5 Likes
Related Questions
Write a program to add titles for the X-axis, Y-axis and for the whole chart in below code.
import matplotlib.pyplot as plt Months = ['Dec', 'Jan', 'Feb', 'Mar'] Attendance = [70, 90, 75, 95] plt.bar(Months, Attendance) plt.show()
plt.plot(A, B) produces (A and B are the sequences same as created in question 1) chart as :
Write code to produce charts as shown below:
Consider the following graph. Write the Python code to plot it. Also add the Title, label for X and Y axis.
Using the following data for plotting the graph
smarks = [10, 40, 30, 60, 55] sname = ["Sahil", "Deepak", "Anil", "Ravi", "Riti"]
Given a data frame df1 as shown below :
1990 2000 2010 a 52 340 890 b 64 480 560 c 78 688 1102 d 94 766 889 Write code to create a scatter chart from the 1990 and 2010 columns of dataframe df1.