Site icon DataFlair

Matplotlib Histograms

Machine Learning courses with 110+ Real-time projects Start Now!!

Program 1

import matplotlib.pyplot as mat
#A histogram is a graph showing frequency distributions.
#It is a graph showing the number of observations within each given interval.
stud_result=[22,25,35,42,45,50,54,67,66,64,70,72,75,79,82,87,89,94,96,98,99]
per_range=[0,30,50,60,70,80,90,100]
#mycolors=['red','green','blue','black','yellow','red','green','blue']
mat.hist(stud_result,per_range,rwidth=0.5,histtype="bar",facecolor='b')
mat.xticks(per_range)
fc={'family':'Times New Roman','size':25,'color':'r'}
fc1={'family':'Times New Roman','size':20,'color':'g'}
fc2={'family':'Verdana','size':20,'color':'b'}

mat.xlabel("Percentage Range",fontdict=fc1)
mat.ylabel("No of Students ",fontdict=fc2)
mat.title("Student Result",fontdict=fc)

mat.show()

 

Exit mobile version