Page 236 - AI Ver 1.0 Class 10
P. 236

Output will be:
                                                                     Maths



                                            Science             21.95%
                                                                                   Eng
                                                      16.59%
                                                                         11.22%




                                                       20.00%         23.90%

                                                SSt
                                                             6.34%             Computers

                                                         2nd Lang

              Histogram
              Histogram represents the frequency of the variable at different points of time. It is used for continuous data and
              the bars created show no gap in between-axis represents the bin ranges while Y-axis gives information about
              frequency.
              Let’s draw a histogram to represent marks out of 100 of 40 students in class.
              Matplotlib uses a built-in function hist() to create a histogram. For example,

                   from matplotlib import pyplot as plt
                   import numpy as np
                   fig,ax = plt.subplots(1,1)
                   marks = np.array([19,16,28,45,37,34,13,49,42,44])
                   ax.hist(marks, bins = [10,20,30,40,50])
                   ax.set_title(“histogram of result”)

                   ax.set_xlabel(‘marks’)
                   ax.set_ylabel(‘no. of students’)
                   plt.show()
              Output will be:
                                                              histogram of result
                                        4.0

                                        3.5
                                        3.0

                                        2.5
                                      no. of students  2.0


                                        1.5
                                        1.0

                                        0.5

                                        0.0
                                             10    15    20    25    30    35    40    45    50
                                                                   marks

                        234   Touchpad Artificial Intelligence-X
   231   232   233   234   235   236   237   238   239   240   241