diff options
Diffstat (limited to 'plotting-data/script.rst')
-rw-r--r-- | plotting-data/script.rst | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/plotting-data/script.rst b/plotting-data/script.rst index b338625..70e5f06 100644 --- a/plotting-data/script.rst +++ b/plotting-data/script.rst @@ -44,13 +44,14 @@ Here we will discuss plotting Experimental data. 2. We will also become familiar with elementwise squaring of such a sequence. -3. We will also see how we can use our graph to indicate Error. +3. How to plot data points using python. + +4. We will also see how we can use our graph to indicate Error. One needs to be familiar with the concepts of plotting mathematical functions in Python. -We will use data from a Simple Pendulum Experiment to illustrate our -points. +We will use data from a Simple Pendulum Experiment to illustrate. .. #[[Anoop: what do you mean by points here? if you mean the points/numbered list in outline slide, then remove the usage point @@ -67,29 +68,28 @@ the square of time,T. We shall be plotting L and T^2 values. First we will have to initiate L and T values. We initiate them as sequence -of values. To tell ipython a sequence of values we write the sequence in -comma seperated values inside two square brackets. This is also called List -so to create two sequences +of values. We define a sequence by comma seperated values inside two square brackets. +This is also called List.Lets create two sequences L and t. .. #[[Anoop: instead of saying "to tell ipython a sequence of values" and make it complicated, we can tell, we define a sequence as]] -L,t type in ipython shell. - .. #[[Anoop: sentence is incomplete, can be removed]] -:: +{{{ Show the initializing L&T slide }}} - In []: L = [0.1, 0.2, 0.3, 0.4, 0.5,0.6, 0.7, 0.8, 0.9] +Type in ipython shell :: + + L = [0.1, 0.2, 0.3, 0.4, 0.5,0.6, 0.7, 0.8, 0.9] - In []: t= [0.69, 0.90, 1.19,1.30, 1.47, 1.58, 1.77, 1.83, 1.94] + t= [0.69, 0.90, 1.19,1.30, 1.47, 1.58, 1.77, 1.83, 1.94] -To obtain the square of sequence t we will use the function square +To obtain the square of sequence t we will use the function square with argument t.This is saved into the variable tsquare.:: - In []: tsquare=square(t) - + tsquare=square(t) + tsqaure array([ 0.4761, 0.81 , 1.4161, 1.69 , 2.1609, 2.4964, 3.1329, 3.3489, 3.7636]) @@ -98,49 +98,51 @@ with argument t.This is saved into the variable tsquare.:: Now to plot L vs T^2 we will simply type :: - In []: plot(L,t,'.') + plot(L,tsquare,'.') .. #[[Anoop: be consistent with the spacing and all.]] '.' here represents to plot use small dots for the point. :: - In []: clf() + clf() You can also specify 'o' for big dots.:: - In []: plot(L,t,'o') + plot(L,tsquare,'o') - In []: clf() + clf() .. #[[Anoop: Make sure code is correct, corrected plot(L,t,o) to plot(L,t,'o')]] -{{{ Slide with Error data included }}} + .. #[[Anoop: again slides are incomplete.]] -Now we shall try and take into account error into our plots . The -Error values for L and T are on your screen.We shall again intialize -the sequence values in the same manner as we did for L and t +For any experimental there is always an error in measurements due to +instrumental and human constaraints.Now we shall try and take into +account error into our plots . The Error values for L and T are on +your screen.We shall again intialize the sequence values in the same +manner as we did for L and t + +The error data we will use is on your screen. +{{{ Show the Adding Error Slide }}} .. #[[Anoop: give introduction to error and say what we are going to do]] :: - In []: delta_L= [0.08,0.09,0.07,0.05,0.06,0.00,0.06,0.06,0.01] - - In []: delta_T= [0.04,0.08,0.11,0.05,0.03,0.03,0.01,0.07,0.01] - - + delta_L= [0.08,0.09,0.07,0.05,0.06,0.00,0.06,0.06,0.01] + delta_T= [0.04,0.08,0.03,0.05,0.03,0.03,0.04,0.07,0.08] Now to plot L vs T^2 with an error bar we use the function errorbar() The syntax of the command is as given on the screen. :: - In []: errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='b.') + errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='b.') 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 @@ -150,18 +152,18 @@ fmt is the format of the plot. similarly we can draw the same error bar with big red dots just change the parameters to fmt to 'ro'. :: - In []: clf() - In []: errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='ro') + clf() + errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='ro') thats it. you can explore other options to errorbar using the documentation of errorbar.:: - In []: errorbar? + errorbar? -{{{ Summary Slides }}} +{{{ Show Summary Slide }}} In this tutorial we have learnt : @@ -182,5 +184,5 @@ This tutorial was created as a part of FOSSEE project. Hope you have enjoyed and found it useful. - Thankyou +Thank You! |