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