0% found this document useful (0 votes)
23 views

Matplotlib Record Programs

Uploaded by

anishkadiyala
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Matplotlib Record Programs

Uploaded by

anishkadiyala
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

MATPLOTLIB

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

import matplotlib.pyplot as plt

Year=[2018,2019,2020,2021,2022]

Pass_Percentage=[85,83,90,82,92]

plt.plot(Year,Pass)

plt.title("Pass percentages in CBSE ")

plt.xticks([2018,2019,2020,2021,2022])

plt.xlabel("Year")

plt.ylabel("Percentage")

plt.show()
OUTPUT

2) Write a program in python to plot histogram. (Height of Bars are


10,1,0,33,6,8)

CODE

import numpy as np

import matplotlib.pyplot as plt

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.title('Histogram of Student Data')

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

import matplotlib.pyplot as plt

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

import matplotlib.pyplot as plt

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

You might also like