Page 462 - AI Ver 3.0 class 10_Flipbook
P. 462
The above code will create a line graph as shown below:
• Multiple line chart
[1]: import matplotlib.pyplot as plt
city=['Delhi', 'Mumbai','Chennai','Kolkata']
day1=[35,21,40,22]
day2=[30,25,36,20]
day3=[24,29,42,24]
plt.xlabel('Metro Cities' )
plt.ylabel('Temp in Celsius')
plt.title('Temperature Study of the Day')
plt.plot(city, day1)
plt.plot(city, day2)
plt.plot(city, day3)
plt.show()
The above code will create a multiple line graph as shown below:
Plotting a bar chart
It is used to plot data using rectangular bars or columns. It is generally used to compare values of two different
categories. Example: marks of 5 subjects to compare, rise in population in five years, changing fuel price every
month.
Various versions of bar charts exist like single bar chart, double bar chart, etc can be used.
Matplotlib uses a built-in function - bar () and plot() to create bar charts.
460 Touchpad Artificial Intelligence (Ver. 3.0)-X

