Matplotlib Histograms

Machine Learning courses with 100+ 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()

 

If you are Happy with DataFlair, do not forget to make us happy with your positive feedback on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *