Some changes to basic-plot.txt.
authorShantanu <shantanu@fossee.in>
Tue, 06 Apr 2010 16:48:23 +0530
changeset 19 b77b9fce62d6
parent 18 27ba96db9d12
child 20 571226041e79
Some changes to basic-plot.txt.
basic-plot.txt
plotting-files.txt
--- a/basic-plot.txt	Mon Apr 05 22:34:25 2010 +0530
+++ b/basic-plot.txt	Tue Apr 06 16:48:23 2010 +0530
@@ -1,7 +1,4 @@
 * Script
-**********
-Some greeting-- Hi or Hello or Welcome - would be polite to start with
-**********
 
 *Hello and welcome to the tutorial on Basic Plotting using Python. This is the first tutorial in a series of tutorials on Python for Scientific Computing. This tutorial is created by the FOSSEE team, IIT Bombay .  
 
@@ -9,8 +6,6 @@
 
 *The goals are to
 help one use Python as a basic plotting tool.
-and understand python as a scripting language.
-
 
 *In this tutorial, we will cover the basics of the Plotting features available in Python. 
 For this we shall use  Ipython and pylab. 
@@ -42,14 +37,14 @@
 Type:
 In []: x = lins<Tab> This is an Ipython feature that will auto-suggest the word
 
-In []  x=linspace(
+In []  x=linspace( RETURN
 oops  I made a mistake . As you can see I made the mistake of not writing command correctly
 and Ipython changed the prompt . To get the old prompt back type crtl-c
 
 In []: x = linspace(0, 2*pi, 50)
 
 
-To obtain the plot we say,
+To obtain the plot we use,
 In []: plot(x, sin(x))
 ***
 As you can see a plot has appeared on the screen. 
@@ -61,15 +56,15 @@
 
 In []: linspace?
 
-It shows documentation related to linspace function. 'help' talks in detail about arguments to be passed, return values, some examples on usage. You can scroll the help using up , down arrows ,  pageup and pagedown keys .
-At any time you want to come out of the help use q key . 
-See how easy it is  to get help in python .  
+It shows documentation related to linspace function. 'help' talks in detail about arguments to be passed, return values, some examples on usage. You can scroll the help using up, and down arrows keys.
+At any time you want to come out of the help use 'q' key. 
+See how easy it is  to get help in IPython.  
 
 *As you can see linspace can take three parameters start, stop, and num and returns num evenly space points . You can scroll through the help to know more about the function
 
 
 In this case we have used two commands 
-'pi' and 'sin' these come from 'pylab'library called using -pylab. 
+'pi' and 'sin' these come from 'pylab' library called using -pylab. 
 
 *Now that we have a basic plot, we can label and title the plot. 
 In []: xla<TAB>bel('x') will add a label to the x-axis. Note that 'x' is enclosed in quotes. 
@@ -78,12 +73,12 @@
 To add a title to plot we simply use 
 In []: tit<TAB>le('Sinusoid').
 
-Hmm we also got the axis's nicely labeled and the plot titled but there is still a important detail left.That might leave a teacher seeing this unsatisfied , it lacks a legend. 
+Hmm we also got the axis's nicely labeled and the plot titled but there is still a important detail left.That might leave a teacher unsatisfied, it lacks a legend. 
 
 Add a legend to the plot by typing 
 In []: legend(['sin(x)'])
 
-Ok what if I want the legend to be in the centre . It just requires us to define one extra parameter. 
+Ok what if I want the legend to be in different location. It just requires us to define one extra parameter. 
 
 We have just typed legend command can we reuse it . Yes 
 
@@ -91,7 +86,7 @@
 
 We can modify previous command to specify the location of the legend, by passing an additional argument to the function. 
 #Ask madhu how to describe the feature here.
-Once you start editing a previous command and then you try to use 'Up arrow key ' you can get commands that are only similar to the command you are editing . But if you move your cursor to the beginning of the line you can get all the previous commands using up and down arrow keys .
+Once you start editing a previous command and then you try to use 'Up arrow key ' you can get commands that are only similar to the command you are editing. But if you move your cursor to the beginning of the line you can get all the previous commands using up and down arrow keys.
 In []: legend(['sin(x)'], loc = 'center')
 
 Note that once 
@@ -99,8 +94,7 @@
 'best' 
 'right'
 
-
-Very often in mathematical plots we have define certain points abd there meaning also called annotating . We next look at how to annotate
+Very often in mathematical plots we have to define certain points and their meaning also called annotating . We next look at how to annotate
 In this case, let's add a comment at the point of origin. 
 In []: annotate('origin', xy=(0, 0))
 
@@ -111,11 +105,7 @@
 We save the plot by the function savefig
 In []: savefig('sin.png') saves the figure with the name 'sin.png' in the current directory. 
 
-
-
-
 #other supported formats are: eps, ps, pdf etc.
-
 When we use plot again by default plots get overlaid.
 In []: plot(x, cos(x))
 
@@ -129,8 +119,6 @@
 In []: clf()
 clears the plot area and starts afresh.
 
-
-
 *In case we want to create multiple plots rather than overlaid plots, we use 'figure' function.
 The figure command is used to open a plain figure window without any plot.
 In []: figure(1)
@@ -147,8 +135,6 @@
 plots cos curve on second window now.
 The previous plot window remains unchanged to these commands.
 
-
-
 calling function figure using argument 1 shifts the focus back to figure(1).
 In []: figure(1)
 
@@ -178,10 +164,9 @@
 
 In []: clf()
 
-
 You may look at more options related to colors and type of lines using plot?(question mark)
 
-quit the documentation using Plot.
+quit the documentation using 'q'
 
 In []: clf()
 
@@ -215,3 +200,9 @@
 ****************
 This brings us to the end of this tutorial.  Thank you for attending this on Python for Scientific Computing .Hope you enjoyed it and found it useful.
 ****************
+
+************
+A slide of review of what has been covered and sequentially/rapidly going through them.
+************
+
+Various problems of Ipython, navigation and enter, exit.
--- a/plotting-files.txt	Mon Apr 05 22:34:25 2010 +0530
+++ b/plotting-files.txt	Tue Apr 06 16:48:23 2010 +0530
@@ -1,115 +1,83 @@
-Hello, this is second tutorial from the series of Python for 
-Scientific computing.
-
-Here we will teach you how to plot experimental data, with two
-variables. Please make sure you have pendulum.txt file, we will
-be using it for introduction of concepts(requirements page!).
-
-We shall look at inputting experimental data and plotting it. 
+**********************************************************************************
+Hello and welcome, this is the second tutorial in the series of spoken tutorials on Python for Scientific computing. 
 
-The data could be input either as lists or read from plain text/
-binary files
+Here we will teach you how to plot experimental data, with two variables.  
 
-# Before starting with this video, you should be comfortable with
-#   - Lists
-#     - initializing them
-#     - appending elements to lists
-#   - for command
-#     - iterating over a list
-#   - split command
-#   - plot command
-#     - plotting two variables
+You could input the data either as a list or read from a plain text/binary file. 
 
-Let's begin with inputting the data as lists and plotting it. 
-
+# Before going through this video, you should have a working knowledge of
+#   - Lists
+#   - How to initialize them
+#   - How to append elements to the lists
+#   - ??? for command
+#   - How to iterate over a list
+#   - How to split a command
+#   - The plot command
+#   - How to plot two variables
+ 
+So let's begin.  First we will input the data as lists and then we will plot it. 
+So on the Terminal window type
 x = [0, 1, 2.1, 3.1, 4.2, 5.2]
-here x is a list. In python list is a container that holds number of
-objects. Various functions related to lists will be covered in more 
-detail later.
+here x is a list. In python, list is a container that holds a number of objects. Various functions related to lists will be covered in more detail later. 
 
-We create one more list to represent corresponding Y values
+Now for the corresponding Y values type
 y = [0, 0.8, 0.9, 0, -0.9, -0.8]
-
-Now we have x and y in two lists and we make a plot of x vs. y. 
+ 
+Now we have x and y in two separate lists and we plot x vs. y.
 plot (x, y, 'o')
-Here, we have our plot!
 
-[We close the plot window. ]
+Here, we have our plot! 
+[We close the plot window. ] 
 
-Now, that we know how to plot data which is in lists, we will look at
-plotting data which is in a text file. Essentially, we read the data
-from the file and massage it into lists again. Then we can easily
-plot it, as we already did. 
+Now, that we know how to plot data from lists, we will look at plotting data from a text file. Essentially, we read the data from the file and massage it into lists again. Then we can easily plot it, as we already did before. 
 
-As an example we will use the data collected from a simple pendulum
-experiment. 
+As an example we will use the data collected from a simple pendulum experiment. Please make sure you have pendulum.txt file, as mentioned on requirement page(link)
 
 In []: cat pendulum.txt (windows?)
-
-The cat command, shows the contents of the file. 
+The cat command shows the file content.
+The first column is the length of the pendulum and the second column is the time. We read the file line-by-line, collect the data into lists and plot them.
 
-The first column is the length of the pendulum and the second column
-is the time. We read the file line-by-line, collect the data into
-lists and plot them. 
-
-We begin with initializing three empty lists for length, time-period
-and square of the time-period. 
-
+We begin with initializing three empty lists for length, time-period and square of the time-period.
 l = []
 t = []
 tsq = []
-
-Now we open the file and read it line by line. 
-for line in open('pendulum.txt'):
-
-':' in end of for statement marks the start of block.
+ 
+Now we open the file and read it line by line.
+for line in open('pendulum.txt'): 
 
-open returns a iterable object which we traverse using for loop. In 
-python for iterates over items of any sequence.
-#we will cover more of 'for' loop in later sections
-line is a string variable storing one line at a time as for loop 
-iterates through file.
+The ':' at the end of the 'for' statement marks the start of the block.
+'open' returns an iterable object which we traverse using the 'for' loop. In  python, 'for' iterates over items of any sequence.
+#we will cover more about the 'for' loop in other spoken tutorials
+'line' is a string variable storing one line at a time as the 'for' loop iterates through the file.
 
 We split each line at the space using
-
-    point = line.split()
-
-split function will return list. In this case it will have two 
-elements, first is length and second being time.
+     point = line.split() 
+split function will return a list. In this case it will have two elements, first is length and second is time. 
 
-mind the indentation here. Everything inside 'for' loop has to be 
-indented by 4 spaces.
-
-Then we append the length and time values to the corresponding
-lists. Note that they are converted from strings to floats, before
-appending to the lists
+Note the indentation here. Everything inside the 'for' loop has to be indented by 4 spaces.
+Then we append the length and time values to the corresponding lists. Note that they are converted from strings to floats, before appending to the lists
     l.append(float(point[0]))
-append is function to append one element to the list.
+append is a function used to append one element to the list.
     t.append(float(point[1]))
 
-By this time we have time and length values in two lists. Now to get
-square of time values we will write one more for loop which this time
-iterate through list 't'
+By now we have the time and length values in two lists. Now to get the square of the time values, we will write one more 'for' loop which will iterate through list 't'
 
 for time in t:
-    tsq.append(time*time)
+    tsq.append(time*time) 
 
-# We also calculate the squares of the time-period and append to the 
-# end of the tsq list. 
+# We also calculate the squares of the time-period and append to the
+# end of the tsq list.
 #     tsq.append(t[-1]*t[-1])
-# For any given list to access last element python provides '-1' 
+# For any given list to access the last element python provides '-1'
 # index, so we use t[-1].
 
-Now lists l(en) and tsq have the required data. We can simply plot 
-them, as we did already.
-
+Now lists l(en) and tsq have the required data. We can simply plot them, as we did earlier. 
 plot(l, tsq, 'o')
 
-Enjoy(Thank you)!
+So here is the required plot. In this way, you can plot data from files.  Hope this information was helpful. See you. 
+
+******************
 
-For alternate ways of loading data from files go through tutorial on 
-loadtxt
-******************
-We should have two tutorials here, one should be basic, using for 
-loops and lists
+For alternate ways of loading data from files go through the tutorial on loadtxt
+We should have two tutorials here, one should be basic, using for loops and lists
 Second one using loadtxt.