plotting_data.rst
changeset 522 d33698326409
equal deleted inserted replaced
521:88a01948450d 522:d33698326409
       
     1 Plotting   Experimental  Data  
       
     2 =============================   
       
     3 Hello  and welcome , this tutorial on  Plotting Experimental data is 
       
     4 presented by the fossee  team.  
       
     5 
       
     6 {{{ Show the slide containing title }}}
       
     7 
       
     8 
       
     9 {{{ Show the Outline Slide }}}
       
    10 
       
    11 Here  we will discuss plotting  Experimental data. 
       
    12 
       
    13 1.We will see how we can represent a sequence of numbers in Python. 
       
    14 
       
    15 2.We will also become fimiliar with  elementwise squaring of such a
       
    16 sequence. 
       
    17 
       
    18 3. We will also see how we can use our graph to indicate Error.
       
    19 
       
    20 One needs   to  be  fimiliar  with  the   concepts  of  plotting
       
    21 mathematical functions in Python.
       
    22 
       
    23 We will use  data from a Simple Pendulum  Experiment to illustrate our
       
    24 points. 
       
    25 
       
    26 {{{ Simple Pendulum data Slide }}} 
       
    27 
       
    28   
       
    29   
       
    30   
       
    31 As we know for a simple pendulum length,L is directly  proportional to 
       
    32 the square of time,T. We shall be plotting L and T^2 values.
       
    33 
       
    34 
       
    35 First  we will have  to initiate L and  T values. We initiate them as sequence 
       
    36 of values.  To tell ipython a sequence of values we  write the sequence in 
       
    37 comma  seperated values inside two square brackets.  This is also  called List 
       
    38 so to create two sequences
       
    39 
       
    40 L,t type in ipython shell. ::
       
    41 
       
    42     In []: L = [0.1, 0.2, 0.3, 0.4, 0.5,0.6, 0.7, 0.8, 0.9]
       
    43     
       
    44     In []: t= [0.69, 0.90, 1.19,1.30, 1.47, 1.58, 1.77, 1.83, 1.94]
       
    45 
       
    46 
       
    47   
       
    48 To obtain the  square of sequence t we will  use the function square
       
    49 with argument t.This is saved into the variable tsquare.::
       
    50 
       
    51    In []: tsquare=square(t)
       
    52   
       
    53    array([  0.4761, 0.81 , 1.4161,  1.69 , 2.1609,  2.4964, 3.1329, 
       
    54    3.3489, 3.7636])
       
    55 
       
    56   
       
    57 Now to plot L vs T^2 we will simply type ::
       
    58 
       
    59   In []: plot(L,t,.)
       
    60 
       
    61 '.' here represents to plot use small dots for the point. ::
       
    62 
       
    63   In []: clf()
       
    64 
       
    65 You can also specify 'o' for big dots.::
       
    66  
       
    67   In []: plot(L,t,o)
       
    68 
       
    69   In []: clf()
       
    70 
       
    71 
       
    72 {{{ Slide with Error data included }}}
       
    73 
       
    74 
       
    75 Now we  shall try  and take into  account error  into our plots . The
       
    76 Error values for L and T  are on your screen.We shall again intialize
       
    77 the sequence values in the same manner as we did for L and t ::
       
    78 
       
    79   In []: delta_L= [0.08,0.09,0.07,0.05,0.06,0.00,0.06,0.06,0.01]
       
    80   
       
    81   In []: delta_T= [0.04,0.08,0.11,0.05,0.03,0.03,0.01,0.07,0.01]
       
    82 
       
    83 
       
    84   
       
    85 Now to plot L vs T^2 with an error bar we use the function errorbar()
       
    86 
       
    87 The syntax of the command is as given on the screen. ::
       
    88 
       
    89     
       
    90     In []: errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='b.')
       
    91 
       
    92 This gives a  plot with error bar for  x and y axis. The  dots are of
       
    93 blue color.
       
    94 
       
    95 
       
    96 similarly we can draw the same error bar with big red dots just change 
       
    97 the parameters to fmt to 'ro'. ::
       
    98 
       
    99     In []: clf()
       
   100     In []: errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='ro')
       
   101 
       
   102 
       
   103 
       
   104 thats it. you can explore other options to errorbar using the documentation 
       
   105 of errorbar.::
       
   106 
       
   107    In []: errorbar?
       
   108 
       
   109 
       
   110 {{{ Summary Slides }}}
       
   111 
       
   112 In this tutorial we have learnt : 
       
   113 
       
   114 1. How to declare a sequence of number , specifically the kind of sequence we learned was a list.
       
   115 
       
   116 2. Plotting experimental data extending our knowledge from mathematical functions. 
       
   117 
       
   118 3. The various options available for plotting dots instead of lines.
       
   119 
       
   120 4. Plotting experimental data such that we can also represent error. We did this using the errorbar() function.
       
   121 
       
   122 
       
   123  {{{ Show the "sponsored by FOSSEE" slide }}}
       
   124 
       
   125 
       
   126 
       
   127 This tutorial was created as a part of FOSSEE project.
       
   128 
       
   129 Hope you have enjoyed and found it useful.
       
   130 
       
   131  Thankyou
       
   132 
       
   133  
       
   134 
       
   135 Author              : Amit Sethi
       
   136 Internal Reviewer   :
       
   137 Internal Reviewer 2 :