Page 212 - Robotics and AI class 10
P. 212

df.plot(kinds'pie',y='Music')

        plot.show()
                                            Pop                      Pop
                                            Rock    Rock
                                            Hip Hop
                                            Country
                                            Jazz
                                                Music                           Jazz







                                                     Hip Hop            Country
        Another example is:
        Example:

        from matplotlib import pyplot as plt
        import numpy as np
        fig = plt.figure()

        ax = fig.add_axes([0,0,1,1])
        ax.axis('equal')
        subjects = ["Eng","Maths","Science","SSt","2nd Lang","Computers"]
        marks = [23, 45, 34, 41,13,49]

        ax.pie(marks, labels = subjects,autopct='%1.2f%%')
        plt.show()
        Output:
                                                              Maths


                                           Science         21.95%
                                                                         Eng
                                                   16.59%
                                                                 11.22%

                                                   20.00%
                                                               23.90%
                                               SSt
                                                            6.34%      Computers

                                                     2nd Lang
        Plotting a Scatter Chart
        Scatter  plots use dots to display values from two variables in a graph  .It is used to plot data  which  has no
        continuity(non continuous data). This allows us to see if there is any relationship or correlation between the two
        variables.
        Matplotlib uses a built-in function - scatter() to create scatterplots.

        Example:
        import matplotlib.pyplot as plt



              210     Touchpad Robotics & Artificial Intelligence-X
   207   208   209   210   211   212   213   214   215   216   217