Page 213 - Robotics and AI class 10
P. 213

marks1=[31,34,36,42,40,23,39]

            marks2 = [34,45,23,44,12,16,35]
            plt.scatter(marks1, marks2, c='red')
            plt.title('Scatter plot')
            plt.xlabel('marks 1')

            plt.ylabel('makrs 2')
            plt.show()
            Output:
                                                             Scatter plot
                                         45

                                        40
                                         35

                                        30
                                        marks 2  25


                                        20
                                        15


                                           22.5  25.0  27.5  30.0  32.5  35.0  37.5  40.0  42.5
                                                               marks 1
            Plotting a Box Plot(Whisker Plot)

            It represents the summary of the set of data values where a box is created for each having properties like minimum,
            first quartile, median, third quartile and maximum. A vertical line goes through the box at the median. Here x-axis
            denotes the data to be plotted while the y-axis shows the frequency distribution.

            Box plots are used to plot outliers and these outliers are plotted outside the graph as dots or circles since they do
            not belong to the range of data and are part of the graph for visualisation.

                                       lower quartile                    upper quartile
                                            Q 1           median             Q 2
                                 min                                                        max


                                     whisker                                       whisker



                                                      interquartile range
            Matplotlib uses a built-in function -boxplot () to create box plots.
            Example:

            import matplotlib.pyplot as plt
            eng = [82,76,24,40,67,62,78,67,72,82]

            maths=[62,5,32,96,95,90,95,15,71,11]
            science=[68,86,19,49,15,16,16,75,65,31]
            sst=[98,10,87,29,72,16,23,72,75,30]
            box_plot_data=[eng,maths,science,sst]

                                                         Introduction to Data and Programming with Python  211
   208   209   210   211   212   213   214   215   216   217   218