Page 463 - AI Ver 3.0 class 10_Flipbook
P. 463
• Using bar()
[1]: # Data for the x-axis and y-axis
city=['Delhi', 'Mumbai','Chennai' ,'Kolkata' ]
day1=[35,21,40,22]
# Creating the bar chart
plt.bar(city, day1)
# Adding labels and title
plt.xlabel('Metro Cities' )
plt.ylabel('Temp in Celsius')
plt. title('Temperature Study of the Day' )
# Displaying the chart
plt.show()
Another example is as follows:
[1]: import matplotlib.pyplot as plt
marks = [23, 45, 34, 41,13,49]
plt.bar(["Eng","Maths","Science","SSt","2nd Lang","Computers"], marks)
plt.title('Bar Chart')
plt.xlabel('Subjects')
plt.ylabel('Marks')
plt.show()
Advance Python (Practical) 461

