Page 126 - Informatics_Practices_Fliipbook_Class12
P. 126

B.  State whether the following statements are True or False:
           1.  Matplotlib line plots may be customised using different marker styles.                    ________
           2.  A bar graph is created using the Matplotlib function plt.bar().                           ________
           3.  The plt.title() method may be used to add a title to a Matplotlib plot.                   ________
           4.  Matplotlib allows us to plot several graphs in a single figure.                           ________
           5.  In Matplotlib, the plt.xlabel() method is used to specify the plot's title.               ________
           6.  Histograms are used for displaying how continuous data is distributed.                    ________
           7.  Bar graphs may be used to depict the distribution of continuous data.                     ________
        C.  Fill in the blanks.
           1.  The ___________ parameter is used to specify the color of a line in a line plot.
           2.  The ___________ parameter is used to specify the line style in a line plot.
           3.  The function used to create a bar graph in matplotlib is ___________.
           4.  To customize the x-axis label in a bar graph, we use the function ___________.
           5.  The bins parameter used to specify the number of bins in a ___________.
        D.  Answer the following questions:
           1.  Consider the following dataset representing the number of website visitors on daily basis recorded for a week:
              [100, 150, 200, 180, 220, 250, 300]
              Write a program to create a line plot with markers to visualize the daily website visitors using Matplotlib.

         Ans.      import matplotlib.pyplot as plt
                  dailyVisitors = [100, 150, 200, 180, 220, 250, 300]
                  weekDays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
                  plt.plot(weekDays, dailyVisitors, marker='o', linestyle='-', color='b')
                  plt.xlabel('Day of the Week')
                  plt.ylabel('Number of Visitors')
                  plt.title('Daily Website Visitors')
                  plt.show()

























                                               Line plot of Daily Website Visitors

           2.  Consider the following two datasets containing the monthly revenue of two companies, namely X and Y, for the first six
              months:
              Dataset X: [100, 120, 150, 130, 140, 160]
              Dataset Y: [80, 90, 110, 100, 120, 130]
              Write Python code using Matplotlib to create a line plot to compare the revenue trends of "Dataset X" and "Dataset Y."

          112  Touchpad Informatics Practices-XII
   121   122   123   124   125   126   127   128   129   130   131