plotting-data/script.rst
changeset 457 68813d8d80fb
parent 434 c8ffd52305ff
equal deleted inserted replaced
456:be96dc6c9743 457:68813d8d80fb
    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 }}}
       
    29 
       
    30 
       
    31 {{{ Show the Outline Slide }}}
    36 {{{ Show the Outline Slide }}}
    32 
    37 
       
    38 .. #[[Anoop: outline slide is missing]]
       
    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. How to plot data points using python.
    41 
    48 
    42 One needs   to  be  fimiliar  with  the   concepts  of  plotting
    49 4. We will also see how we can use our graph to indicate Error.
       
    50 
       
    51 One needs   to  be  familiar  with  the   concepts  of  plotting
    43 mathematical functions in Python.
    52 mathematical functions in Python.
    44 
    53 
    45 We will use  data from a Simple Pendulum  Experiment to illustrate our
    54 We will use  data from a Simple Pendulum Experiment to illustrate. 
    46 points. 
    55 
       
    56 .. #[[Anoop: what do you mean by points here? if you mean the
       
    57    points/numbered list in outline slide, then remove the usage point
       
    58    from here.]]
    47 
    59 
    48 {{{ Simple Pendulum data Slide }}} 
    60 {{{ Simple Pendulum data Slide }}} 
    49 
    61 
    50   
    62 .. #[[Anoop: slides are incomplete, work on slides and context
       
    63    switches]]
    51   
    64   
    52   
    65   
    53 As we know for a simple pendulum length,L is directly  proportional to 
    66 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.
    67 the square of time,T. We shall be plotting L and T^2 values.
    55 
    68 
    56 
    69 
    57 First  we will have  to initiate L and  T values. We initiate them as sequence 
    70 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 
    71 of values.  We define a sequence by comma seperated values inside two square brackets.  
    59 comma  seperated values inside two square brackets.  This is also  called List 
    72 This is also  called List.Lets create two sequences L and t.
    60 so to create two sequences
    73 
    61 
    74 .. #[[Anoop: instead of saying "to tell ipython a sequence of values"
    62 L,t type in ipython shell. ::
    75    and make it complicated, we can tell, we define a sequence as]]
    63 
    76 
    64     In []: L = [0.1, 0.2, 0.3, 0.4, 0.5,0.6, 0.7, 0.8, 0.9]
    77 .. #[[Anoop: sentence is incomplete, can be removed]]
       
    78 
       
    79 {{{ Show the initializing L&T slide }}}
       
    80 
       
    81 Type in ipython shell ::
       
    82 
       
    83     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     t= [0.69, 0.90, 1.19,1.30, 1.47, 1.58, 1.77, 1.83, 1.94]
    67 
    86 
    68 
    87  
    69   
    88 To obtain the square of sequence t we will use the function square
    70 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    tsquare=square(t)
    74   
    92    tsqaure
    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   plot(L,tsquare,'.')
       
   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   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   plot(L,tsquare,'o')
    90 
   112 
    91   In []: clf()
   113   clf()
    92 
   114 
    93 
   115 
    94 {{{ Slide with Error data included }}}
   116 Following are exercises that you must do.
    95 
   117 
    96 
   118 %% %% Plot the given experimental data with large dots.The data is
    97 Now we  shall try  and take into  account error  into our plots . The
   119 on your screen. 
    98 Error values for L and T  are on your screen.We shall again intialize
   120  
    99 the sequence values in the same manner as we did for L and t ::
   121 %% %% Plot the given experimental data with small dots.
   100 
   122 The data is on your screen
   101   In []: delta_L= [0.08,0.09,0.07,0.05,0.06,0.00,0.06,0.06,0.01]
   123 
   102   
   124 
   103   In []: delta_T= [0.04,0.08,0.11,0.05,0.03,0.03,0.01,0.07,0.01]
   125 Please, pause the video here. Do the exercises and then continue. 
   104 
   126 
   105 
   127 
       
   128 
       
   129 
       
   130 
       
   131 .. #[[Anoop: Make sure code is correct, corrected plot(L,t,o) to
       
   132    plot(L,t,'o')]]
       
   133 
       
   134 
       
   135 
       
   136 .. #[[Anoop: again slides are incomplete.]]
       
   137 
       
   138 For any experimental there is always an error in measurements due to
       
   139 instrumental and human constaraints.Now we shall try and take into
       
   140 account error into our plots . The Error values for L and T are on
       
   141 your screen.We shall again intialize the sequence values in the same
       
   142 manner as we did for L and t
       
   143 
       
   144 The error data we will use is on your screen.
       
   145 
       
   146 {{{ Show the Adding Error Slide }}}
       
   147 .. #[[Anoop: give introduction to error and say what we are going to
       
   148    do]]
       
   149 
       
   150 ::
       
   151 
       
   152     delta_L= [0.08,0.09,0.07,0.05,0.06,0.00,0.06,0.06,0.01]
       
   153     delta_T= [0.04,0.08,0.03,0.05,0.03,0.03,0.04,0.07,0.08]
   106   
   154   
   107 Now to plot L vs T^2 with an error bar we use the function errorbar()
   155 Now to plot L vs T^2 with an error bar we use the function errorbar()
   108 
   156 
   109 The syntax of the command is as given on the screen. ::
   157 The syntax of the command is as given on the screen. ::
   110 
   158 
   111     
   159     
   112     In []: errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='b.')
   160     errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='b.')
   113 
   161 
   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. 
   162 This gives a plot with error bar for x and y axis. The dots are of
   115 
   163 blue color. The parameters xerr and yerr are error on x and y axis and
   116 
   164 fmt is the format of the plot.
   117 similarly we can draw the same error bar with big red dots just change 
   165 
       
   166 
       
   167 similarly we can draw the same error bar with big red dots just change
   118 the parameters to fmt to 'ro'. ::
   168 the parameters to fmt to 'ro'. ::
   119 
   169 
   120     In []: clf()
   170     clf()
   121     In []: errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='ro')
   171     errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='ro')
   122 
   172 
   123 
   173 
   124 
   174 
   125 thats it. you can explore other options to errorbar using the documentation 
   175 thats it. you can explore other options to errorbar using the documentation 
   126 of errorbar.::
   176 of errorbar.::
   127 
   177 
   128    In []: errorbar?
   178    errorbar?
   129 
   179 
   130 
   180 Following is an  exercise that you must do.
   131 {{{ Summary Slides }}}
   181 
   132 
   182 %% %% Plot the given experimental data with large green dots.Also include
   133 In this tutorial we have learnt : 
   183 the error in your plot. 
   134 
   184 
   135 1. How to declare a sequence of number , specifically the kind of sequence we learned was a list.
   185 Please, pause the video here. Do the exercise and then continue. 
   136 
   186 
   137 2. Plotting experimental data extending our knowledge from mathematical functions. 
   187 
   138 
   188 
   139 3. The various options available for plotting dots instead of lines.
   189 
   140 
   190 
   141 4. Plotting experimental data such that we can also represent error. We did this using the errorbar() function.
   191 
       
   192 
       
   193 {{{ Show Summary Slide }}}
       
   194 
       
   195 In this tutorial we have learnt :
       
   196 
       
   197 
       
   198 
       
   199 1. How to declare a sequence of numbers.
       
   200 
       
   201 2. Plotting experimental data.
       
   202 
       
   203 #. The various options available for plotting dots instead of lines.
       
   204 
       
   205 #. Plotting experimental data such that we can also represent error. 
       
   206 
   142 
   207 
   143 
   208 
   144  {{{ Show the "sponsored by FOSSEE" slide }}}
   209  {{{ Show the "sponsored by FOSSEE" slide }}}
   145 
   210 
   146 
   211 .. #[[Anoop: again slides are incomplete]]
   147 
   212 
   148 This tutorial was created as a part of FOSSEE project.
   213 This tutorial was created as a part of FOSSEE project.
   149 
   214 
   150 Hope you have enjoyed and found it useful.
   215 Hope you have enjoyed and found it useful.
   151 
   216 
   152  Thankyou
   217 Thank You!
   153 
   218 
   154  
       
   155 
       
   156 Author              : Amit Sethi
       
   157 Internal Reviewer   :
       
   158 Internal Reviewer 2 :