multiple_plots/questions.rst
changeset 522 d33698326409
equal deleted inserted replaced
521:88a01948450d 522:d33698326409
       
     1 Objective Questions
       
     2 -------------------
       
     3 
       
     4 .. A mininum of 8 questions here (along with answers)
       
     5 
       
     6 1. Multiple plots appear in different figures by default. True or False?
       
     7 
       
     8    Answer: False
       
     9 
       
    10 #. What command is used to get individual plots separately?
       
    11 
       
    12    Answer: Figure
       
    13 
       
    14 #. Which figure is closed after the following commands are run? 
       
    15 
       
    16 :: 
       
    17 
       
    18   x = linspace(0, 50, 500)
       
    19   figure(1)
       
    20   plot(x, sin(x), 'b')
       
    21   figure(2)
       
    22   plot(x, cos(x), 'g')
       
    23   xlabel('x')
       
    24   ylabel('cos(x)')
       
    25   close()
       
    26 
       
    27   Answer: Figure 2
       
    28 
       
    29 #. Describe the plot obtained by the following commands::
       
    30 
       
    31   x = linspace(0, 50, 500)
       
    32   subplot(2, 1, 1)
       
    33   plot(x, sin(x), 'b')    
       
    34 
       
    35 Answer: A figure window with space for 2 plots one below the other is
       
    36         obtained. The sine plot with blue line appears in the first row. 
       
    37 
       
    38 #. Describe the plot obtained by the following commands::
       
    39 
       
    40   x = linspace(0, 50, 500)
       
    41   subplot(2, 1, 1)
       
    42   plot(x, sin(x), 'b')
       
    43   subplot(2, 1, 2)
       
    44   plot(x, cos(x), 'g')
       
    45 
       
    46   Answer: 2 plots one below another. sine in blue on first row. cosine
       
    47   in green in the second row. 
       
    48 
       
    49 #. Describe the plot obtained by the following commands::
       
    50 
       
    51   x = linspace(0, 50, 500)
       
    52   subplot(2, 1, 1)
       
    53   plot(x, sin(x), 'b')
       
    54   subplot(2, 1, 2)
       
    55   plot(x, cos(x), 'g')
       
    56   subplot(2, 1, 1)
       
    57   plot(x, tan(x), 'r')
       
    58 
       
    59   Answer: 2 plots one below another. tan in red on first row. cosine
       
    60   in green in the second row. 
       
    61 
       
    62   
       
    63 #. Which of the following gives the correct legend for the commands below
       
    64    
       
    65    a. legend([sin, cos, tan])
       
    66    #. legend([tan, cos, sin])
       
    67    #. legend[(tan, cos, sin)]
       
    68    #. legend(['sin', 'cos', 'tan'])
       
    69    #. legend(['tan', 'cos', 'sin'])
       
    70 
       
    71 ::
       
    72 
       
    73   x = linspace(0, 50, 500)
       
    74   figure(1)
       
    75   plot(x, sin(x), 'b')
       
    76   figure(2)
       
    77   plot(x, cos(x), 'g')
       
    78   figure(3)
       
    79   plot(x, tan(x), 'b')
       
    80 
       
    81    Answer: legend(['tan', 'cos', 'sin'])
       
    82 
       
    83 Larger Questions
       
    84 ----------------
       
    85 
       
    86 .. A minimum of 2 questions here (along with answers)
       
    87 
       
    88 1. Question 1
       
    89 2. Question 2