plotting-data/script.rst
changeset 399 3c16961361cd
parent 372 8e05616c4102
child 416 06ac45f4de88
equal deleted inserted replaced
398:36295bb91766 399:3c16961361cd
    14 
    14 
    15 ..   1. getting started with plotting
    15 ..   1. getting started with plotting
    16 
    16 
    17      
    17      
    18 .. Author              : Amit 
    18 .. Author              : Amit 
    19    Internal Reviewer   :  
    19    Internal Reviewer   : Anoop Jacob Thomas<anoop@fossee.in> 
    20    External Reviewer   :
    20    External Reviewer   :
    21    Checklist OK?       : <put date stamp here, if OK> [2010-10-05]
    21    Checklist OK?       : <put date stamp here, if OK> [2010-10-05]
    22 
    22 
       
    23 .. #[[Anoop: Add quickref]]
       
    24 .. #[[Anoop: Slides are incomplete, add summary slide, thank you slide
       
    25    etc.]]
       
    26 
       
    27 ===============================
    23 Plotting   Experimental  Data  
    28 Plotting   Experimental  Data  
    24 =============================   
    29 ===============================   
       
    30 
       
    31 {{{ Show the slide containing title }}}
       
    32 
    25 Hello  and welcome , this tutorial on  Plotting Experimental data is 
    33 Hello  and welcome , this tutorial on  Plotting Experimental data is 
    26 presented by the fossee  team.  
    34 presented by the fossee  team.  
    27 
    35 
    28 {{{ Show the slide containing title }}}
    36 {{{ Show the Outline Slide }}}
    29 
    37 
    30 
    38 .. #[[Anoop: outline slide is missing]]
    31 {{{ Show the Outline Slide }}}
       
    32 
    39 
    33 Here  we will discuss plotting  Experimental data. 
    40 Here  we will discuss plotting  Experimental data. 
    34 
    41 
    35 1. We will see how we can represent a sequence of numbers in Python. 
    42 1. We will see how we can represent a sequence of numbers in Python. 
    36 
    43 
    37 2. We will also become fimiliar with  elementwise squaring of such a
    44 2. We will also become familiar with  elementwise squaring of such a
    38 sequence. 
    45 sequence. 
    39 
    46 
    40 3. We will also see how we can use our graph to indicate Error.
    47 3. We will also see how we can use our graph to indicate Error.
    41 
    48 
    42 One needs   to  be  fimiliar  with  the   concepts  of  plotting
    49 One needs   to  be  familiar  with  the   concepts  of  plotting
    43 mathematical functions in Python.
    50 mathematical functions in Python.
    44 
    51 
    45 We will use  data from a Simple Pendulum  Experiment to illustrate our
    52 We will use  data from a Simple Pendulum  Experiment to illustrate our
    46 points. 
    53 points. 
    47 
    54 
       
    55 .. #[[Anoop: what do you mean by points here? if you mean the
       
    56    points/numbered list in outline slide, then remove the usage point
       
    57    from here.]]
       
    58 
    48 {{{ Simple Pendulum data Slide }}} 
    59 {{{ Simple Pendulum data Slide }}} 
    49 
    60 
    50   
    61 .. #[[Anoop: slides are incomplete, work on slides and context
       
    62    switches]]
    51   
    63   
    52   
    64   
    53 As we know for a simple pendulum length,L is directly  proportional to 
    65 As we know for a simple pendulum length,L is directly  proportional to 
    54 the square of time,T. We shall be plotting L and T^2 values.
    66 the square of time,T. We shall be plotting L and T^2 values.
    55 
    67 
    57 First  we will have  to initiate L and  T values. We initiate them as sequence 
    69 First  we will have  to initiate L and  T values. We initiate them as sequence 
    58 of values.  To tell ipython a sequence of values we  write the sequence in 
    70 of values.  To tell ipython a sequence of values we  write the sequence in 
    59 comma  seperated values inside two square brackets.  This is also  called List 
    71 comma  seperated values inside two square brackets.  This is also  called List 
    60 so to create two sequences
    72 so to create two sequences
    61 
    73 
    62 L,t type in ipython shell. ::
    74 .. #[[Anoop: instead of saying "to tell ipython a sequence of values"
       
    75    and make it complicated, we can tell, we define a sequence as]]
       
    76 
       
    77 L,t type in ipython shell.
       
    78 
       
    79 .. #[[Anoop: sentence is incomplete, can be removed]]
       
    80 
       
    81 ::
    63 
    82 
    64     In []: L = [0.1, 0.2, 0.3, 0.4, 0.5,0.6, 0.7, 0.8, 0.9]
    83     In []: L = [0.1, 0.2, 0.3, 0.4, 0.5,0.6, 0.7, 0.8, 0.9]
    65     
    84     
    66     In []: t= [0.69, 0.90, 1.19,1.30, 1.47, 1.58, 1.77, 1.83, 1.94]
    85     In []: t= [0.69, 0.90, 1.19,1.30, 1.47, 1.58, 1.77, 1.83, 1.94]
    67 
    86 
    68 
    87  
    69   
       
    70 To obtain the  square of sequence t we will  use the function square
    88 To obtain the  square of sequence t we will  use the function square
    71 with argument t.This is saved into the variable tsquare.::
    89 with argument t.This is saved into the variable tsquare.::
    72 
    90 
    73    In []: tsquare=square(t)
    91    In []: tsquare=square(t)
    74   
    92   
    75    array([  0.4761, 0.81 , 1.4161,  1.69 , 2.1609,  2.4964, 3.1329, 
    93    array([  0.4761, 0.81 , 1.4161,  1.69 , 2.1609,  2.4964, 3.1329, 
    76    3.3489, 3.7636])
    94    3.3489, 3.7636])
    77 
    95 
       
    96 .. #[[Anoop: how do you get the array([ 0.4761 ....]) output?]]
       
    97 
    78   
    98   
    79 Now to plot L vs T^2 we will simply type ::
    99 Now to plot L vs T^2 we will simply type ::
    80 
   100 
    81   In []: plot(L,t,.)
   101   In []: plot(L,t,'.')
       
   102 
       
   103 .. #[[Anoop: be consistent with the spacing and all.]]
    82 
   104 
    83 '.' here represents to plot use small dots for the point. ::
   105 '.' here represents to plot use small dots for the point. ::
    84 
   106 
    85   In []: clf()
   107   In []: clf()
    86 
   108 
    87 You can also specify 'o' for big dots.::
   109 You can also specify 'o' for big dots.::
    88  
   110  
    89   In []: plot(L,t,o)
   111   In []: plot(L,t,'o')
    90 
   112 
    91   In []: clf()
   113   In []: clf()
    92 
   114 
    93 
   115 
       
   116 .. #[[Anoop: Make sure code is correct, corrected plot(L,t,o) to
       
   117    plot(L,t,'o')]]
       
   118 
    94 {{{ Slide with Error data included }}}
   119 {{{ Slide with Error data included }}}
    95 
   120 
       
   121 .. #[[Anoop: again slides are incomplete.]]
    96 
   122 
    97 Now we  shall try  and take into  account error  into our plots . The
   123 Now we  shall try  and take into  account error  into our plots . The
    98 Error values for L and T  are on your screen.We shall again intialize
   124 Error values for L and T  are on your screen.We shall again intialize
    99 the sequence values in the same manner as we did for L and t ::
   125 the sequence values in the same manner as we did for L and t
       
   126 
       
   127 .. #[[Anoop: give introduction to error and say what we are going to
       
   128    do]]
       
   129 
       
   130 ::
   100 
   131 
   101   In []: delta_L= [0.08,0.09,0.07,0.05,0.06,0.00,0.06,0.06,0.01]
   132   In []: delta_L= [0.08,0.09,0.07,0.05,0.06,0.00,0.06,0.06,0.01]
   102   
   133   
   103   In []: delta_T= [0.04,0.08,0.11,0.05,0.03,0.03,0.01,0.07,0.01]
   134   In []: delta_T= [0.04,0.08,0.11,0.05,0.03,0.03,0.01,0.07,0.01]
   104 
   135 
   109 The syntax of the command is as given on the screen. ::
   140 The syntax of the command is as given on the screen. ::
   110 
   141 
   111     
   142     
   112     In []: errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='b.')
   143     In []: errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='b.')
   113 
   144 
   114 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. 
   145 This gives a plot with error bar for x and y axis. The dots are of
       
   146 blue color. The parameters xerr and yerr are error on x and y axis and
       
   147 fmt is the format of the plot.
   115 
   148 
   116 
   149 
   117 similarly we can draw the same error bar with big red dots just change 
   150 similarly we can draw the same error bar with big red dots just change
   118 the parameters to fmt to 'ro'. ::
   151 the parameters to fmt to 'ro'. ::
   119 
   152 
   120     In []: clf()
   153     In []: clf()
   121     In []: errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='ro')
   154     In []: errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='ro')
   122 
   155 
   141 4. Plotting experimental data such that we can also represent error. We did this using the errorbar() function.
   174 4. Plotting experimental data such that we can also represent error. We did this using the errorbar() function.
   142 
   175 
   143 
   176 
   144  {{{ Show the "sponsored by FOSSEE" slide }}}
   177  {{{ Show the "sponsored by FOSSEE" slide }}}
   145 
   178 
   146 
   179 .. #[[Anoop: again slides are incomplete]]
   147 
   180 
   148 This tutorial was created as a part of FOSSEE project.
   181 This tutorial was created as a part of FOSSEE project.
   149 
   182 
   150 Hope you have enjoyed and found it useful.
   183 Hope you have enjoyed and found it useful.
   151 
   184 
   152  Thankyou
   185  Thankyou
   153 
   186 
   154  
       
   155 
       
   156 Author              : Amit Sethi
       
   157 Internal Reviewer   :
       
   158 Internal Reviewer 2 :