Page 107 - Informatics_Practices_Fliipbook_Class12
P. 107

Recall that r denotes the red color, * denotes the use of asterisks to mark the end points of the line segments,
            and -- denotes the dotted line. So, we invoke the method plt.plot() with three arguments: time, velocity,
            and 'r*--':
             >>> import matplotlib.pyplot as plt
             >>> time = [2, 4, 6, 8, 10]
             >>> velocity = [30, 40, 60, 35, 10]
             >>> plt.plot(time, velocity, 'r*--')
             >>> plt.show()
























                                                     Fig 3.3: Line joining points

            The above statement creates a line plot by (Fig 3.3) connecting the data points specified by the time and velocity lists.
            The 'r*--' parameter specifies the appearance of the line plot:

                'r': Specifies the color as red.
                '*': Specifies the marker style for the data points as asterisks.
                '--': Specifies the line style as dashed.


             C T  01     Modify the above code to plot the same graph as above, except that the solid lines should be
                         in green colour, and uptriangles should be used to denote the end points of the line segments
                         as shown in Figure 4.




























                                                     Fig 3.4: Line joining points

                                                                                              Data Visualization  93
   102   103   104   105   106   107   108   109   110   111   112