plotting-data/plotting-data.rst
changeset 322 3cacbcad4c42
equal deleted inserted replaced
321:2e49b1b72996 322:3cacbcad4c42
       
     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 blue color. The parameters xerr and yerr are error on x and y axis and fmt is the format of the plot. 
       
    93 
       
    94 
       
    95 similarly we can draw the same error bar with big red dots just change 
       
    96 the parameters to fmt to 'ro'. ::
       
    97 
       
    98     In []: clf()
       
    99     In []: errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='ro')
       
   100 
       
   101 
       
   102 
       
   103 thats it. you can explore other options to errorbar using the documentation 
       
   104 of errorbar.::
       
   105 
       
   106    In []: errorbar?
       
   107 
       
   108 
       
   109 {{{ Summary Slides }}}
       
   110 
       
   111 In this tutorial we have learnt : 
       
   112 
       
   113 1. How to declare a sequence of number , specifically the kind of sequence we learned was a list.
       
   114 
       
   115 2. Plotting experimental data extending our knowledge from mathematical functions. 
       
   116 
       
   117 3. The various options available for plotting dots instead of lines.
       
   118 
       
   119 4. Plotting experimental data such that we can also represent error. We did this using the errorbar() function.
       
   120 
       
   121 
       
   122  {{{ Show the "sponsored by FOSSEE" slide }}}
       
   123 
       
   124 
       
   125 
       
   126 This tutorial was created as a part of FOSSEE project.
       
   127 
       
   128 Hope you have enjoyed and found it useful.
       
   129 
       
   130  Thankyou
       
   131 
       
   132  
       
   133 
       
   134 Author              : Amit Sethi
       
   135 Internal Reviewer   :
       
   136 Internal Reviewer 2 :