Matplotlib Record Programs
Matplotlib Record Programs
1) Write a python program to plot a line chart based on the given data to
depict the pass percentage of students in CBSE exams for the years 2019 to
2023 as shown below.
Year=[2019, 2020,2021,2022,2023]
Pass_Percentage=[85,83,90,82,92]
CODE
Year=[2018,2019,2020,2021,2022]
Pass_Percentage=[85,83,90,82,92]
plt.plot(Year,Pass)
plt.xticks([2018,2019,2020,2021,2022])
plt.xlabel("Year")
plt.ylabel("Percentage")
plt.show()
OUTPUT
CODE
import numpy as np
plt.hist([0,10,20,30,40,50],bins=[0,10,20,30,40,50,60],weights=[10,1,0,3
3,6,8],edgecolor='yellow')
plt.xlabel('value')
plt.ylabel('Frequency')
plt.show()
OUTPUT
3) Write a python program to plot a bar chart based on the given data to
depict class wise number of students.
Classes=[IX,X,XI,XII]
Students=[30,40,20,30]
CODE
classes=['IX','X','XI','XII']
students=[30,40,20,30]
plt.bar(classes,students)
plt.xlabel('class')
plt.ylabel('Number of students')
plt.show()
OUTPUT
4) Write a python program to plot a bar horizontal chart based on the given data
to depict number of runs per over.
overs=[1,2,3,4,5]
runs=[10,17,12,10,20]
CODE
overs=[1,2,3,4,5]
runs=[10,17,12,10,20]
plt.barh(overs,runs)
plt.xlabel('overs')
plt.ylabel('runs')
plt.title('cricket')
plt.grid(True)
plt.show()
OUTPUT