summaryrefslogtreecommitdiff
path: root/using_plot_interactively
diff options
context:
space:
mode:
authorJovina D'Souza2011-04-25 12:10:50 +0530
committerJovina D'Souza2011-04-25 12:10:50 +0530
commit8a8ee62d543a0f923f00f7a90eacd701b6bc98b7 (patch)
tree4c2d53d724066aba8fcf51f32f13e07627f64bde /using_plot_interactively
parent04d250dd3b5e8cf32d1716f1539e5cf4347af785 (diff)
downloadst-scripts-8a8ee62d543a0f923f00f7a90eacd701b6bc98b7.tar.gz
st-scripts-8a8ee62d543a0f923f00f7a90eacd701b6bc98b7.tar.bz2
st-scripts-8a8ee62d543a0f923f00f7a90eacd701b6bc98b7.zip
modified script.
Diffstat (limited to 'using_plot_interactively')
-rw-r--r--using_plot_interactively/script.rst242
1 files changed, 157 insertions, 85 deletions
diff --git a/using_plot_interactively/script.rst b/using_plot_interactively/script.rst
index cd2ee6a..a1e6727 100644
--- a/using_plot_interactively/script.rst
+++ b/using_plot_interactively/script.rst
@@ -21,203 +21,275 @@
Script
-------
+.. L1
+
{{{ Show the Title Slide }}}
-Hello and welcome to the tutorial on creating simple plots using
-Python.This tutorial is presented by the Fossee group.
+.. R1
+Hello Friends and welcome to the tutorial on creating simple plots using
+iPython.
I hope you have IPython running on your computer.
-In this tutorial we will look at plot command and also how to study
-the plot using the UI.
+.. L2
+
+{{{ Show Objective Slide }}}
+
+.. R2
-{{{ Show Outline Slide }}}
+In this tutorial we will learn how to plot using the plot command and how to use the user interface of plot figure.
-Lets start ipython on your shell, type ::
+.. R3
- $ipython -pylab
+Lets start ipython.Open the terminal and type
+ipython -pylab and hit enter.
+.. L3
+
+:: ipython -pylab
+
+.. R4
Pylab is a python library which provides plotting functionality.It
-also provides many other important mathematical and scientific
-functions. After running IPython -pylab in your shell if at the top of
-the result of this command, you see something like ::
-
+provides many other important mathematical and scientific
+functions. After running IPython -pylab in the shell you will see some
+information about ipython and pylab followed by the In[1] prompt.But if you get an error like ::
`ERROR: matplotlib could NOT be imported! Starting normal
IPython.`
+Then you will have to install the matplotlib and run this command again.
-{{{ Slide with Error written on it }}}
-
+.. L4
-Then you have to install matplotlib and run this command again.
+{{{ Slide with Error written on it }}}
-Now type in your ipython shell ::
+.. R5
- linpace?
+Now type 'linspace' followed by a '?' mark in your ipython shell
+
+.. L5
+ linspace?
+.. R6
as the documentation says, it returns `num` evenly spaced samples,
calculated over the interval start and stop. To illustrate this, lets
-do it form 1 to 100 and try 100 points. ::
+try to generate 100 points.Type ``linspace(1,100,100)`` and hit enter.
+As you can see a sequence of numbers from 1 to 100 appears.
- linspace(1,100,100)
+.. L6
-As you can see a sequence of numbers from 1 to 100 appears.
+ linspace(1,100,100)
-Now lets try 200 points between 0 and 1 you do this by typing ::
+.. R7
+Now lets try to generate 200 points between 0 and 1,we do that by typing linspace(0,1,200).
+
+.. L7
linspace(0,1,200)
-0 for start , 1 for stop and 200 for no of points. In linspace
-the start and stop points can be integers, decimals , or
-constants. Let's try and get 100 points between -pi to pi. Type ::
-
- p = linspace(-pi,pi,100)
+.. R8
+Here,0 is the start , 1 the stop and 200 the number of points.In linspace
+the start and stop points can be integers, decimals , or constants.
+Let's try and get 100 points between -pi to pi.Here 'pi' is a constant
+defined by pylab. Save this to the variable,say p.
+
+.. L8
-'pi' here is constant defined by pylab. Save this to the variable, p
-.
+ :: p = linspace(-pi,pi,100)
-If you now ::
-
- len(p)
+.. R9
-You will get the no. of points. len function gives the no of elements
+If we now type ``len(p)``
+we will get the no. of points. len function gives the no of elements
of a sequence.
+.. L9
+
+ :: len(p)
+
-Let's try and plot a cosine curve between -pi and pi using these
-points. Simply type::
+.. R10
- plot(p,cos(points))
+Let's try and plot a cosine curve between -pi and pi.For this we use the plot command.
+Here cos(p) gets the cosine value at every point
+corresponding to point p.
+.. L10
-Here cos(points) gets the cosine value at every corresponding point to
-p.
+ :: plot(p,cos(p))
+.. R11
-We can also save cos(points) to variable cosine and plot it using
-plot.::
+We can save cos(p) to variable cosine and then plot it using the
+plot function.::
- cosine=cos(points)
+.. L11
+
+ cosine=cos(p)
plot(p,cosine)
-
+.. R12
-Now do ::
-
- clf()
+Now to clear the plot ,we use the ``clf()`` function ::
-this will clear the plot.
+.. L12
+
+ clf()
-This is done because any other plot we try to make shall come on the
-same drawing area. As we do not wish to clutter the area with
-overlaid plots , we just clear it with clf(). Now lets try a sine
-plot. ::
+.. R13
+This is done because if we wish to make another plot,it will overlap the previous plot.
+As we do not wish to clutter the area with overlaid plots , we just clear it with clf().
+Now lets try a sine plot.
+.. L13
- plot(p,sin(p))
+ :: plot(p,sin(p))
+.. R14
+We can study the plot better on the plot window by using the various options available on it.Let us have a look at these options.
-
-The Window on which the plot appears can be used to study it better.
+.. L14
{{{ Show the slide with all the buttons on it }}}
-First of all moving the mouse around gives us the point where mouse
-points at.
+.. R15
-Also we have some buttons the right most among them is
+As we can observe, moving the mouse pointer along the plot gives us the location of each point on the plot
+
+.. L15
+
+{{Move the mouse along the plot}}
+
+.. R16
+
+To the bottom left of the window,there are a few buttons.The right most among them is
for saving the file.
+Just click on it and type the file name. We will save the plot
+by the name `sin_curve` in pdf format.As you can see we can specify the format
+of file from the dropdown.Formats like png ,eps ,pdf, ps are available.
-Just click on it specifying the name of the file. We will save the plot
-by the name sin_curve in pdf format.
+.. L16
+{{{ Save the plot as ``sin_curve`` in pdf format }}}
+.. R17
-{{{ Show how to save the file }}}
+Left to the save button is the slider button by which we can specify the margins.
-As you can see I can specify format of file from the dropdown.
+.. L17
-Formats like png ,eps ,pdf, ps are available.
+{{{Point the mouse on the slider button}}}
-Left to the save button is the slider button to specify the margins.
+.. L18
{{{ Show how to zoom. Press zoom button and specify region to zoom }}}
-Left to this is zoom button to zoom into the plot. Just specify the
+.. R18
+
+Left to this is the zoom button by which we can zoom into the plot. Just specify the
region to zoom into.
+.. L19
+
{{{ Press Move button and move the axes. }}}
-The button left to it can be used to move the axes of the plot.
+.. R19
+
+The button to the left of it can be used to move the axes of the plot.
+
+.. L20
{{{ Press Back and Forward Button }}}
-
-The next two buttons with a left and right arrow icons change the state of the
-plot and take it to the previous state it was in. It more or less acts like a
-back and forward button in the browser.
+
+.. R20
+
+The next two buttons with left and right arrow icons change the state of the
+plot and take it to the previous state it was in. It more or less acts like the
+back and forward button in a browser.
+
+.. L21
{{{ Press home button }}}
+.. R21
+
The last one is 'home' referring to the initial plot.
+.. L22
+{{{Show slide with question 1}}}
+.. R22
-Following is an exercise that you must do.
+Following is an exercise that you must do.Please, pause the video and do the exercise.
%% %% Plot (sin(x)*sin(x))/x .
1. Save the plot by the sinsquarebyx.pdf in pdf format.
2. Zoom and find the maxima.
-
3. Bring it back to initial position.
+.. L23
-Please, pause the video here. Do the exercise and then continue.
+{{{ Summary Slide }}}
+.. R23
+Let's revise quickly what we have learnt today
+1. To Start Ipython with pylab
+2. To Use the linspace function to create `num` equally spaced points in a region.
+3. To Find the length of sequnces using len function
+
+4. To Plot mathematical functions using plot.
+5. To Clear drawing area using clf
+
+5. To Use the UI of plot for studying it better and using functionalities like save , zoom
+and moving the plots on x and y axis
+.. L24
+{{Show self assessment questions slide}}
-{{{ Summary Slide }}}
+1. Create 100 equally spaced points between -pi/2 and pi/2?
-In this tutorial we have looked at
+2. How do you clear a figure in ipython?
-1. Starting Ipython with pylab
+3. How do find the length of a sequence?
-2. Using linspace function to create `num` equaly spaced points in a region.
+.. R24
-3. Finding length of sequnces using len.
-
-4. Plotting mathematical functions using plot.
+.. L25
-4. Clearing drawing area using clf
-
-5. Using the UI of plot for studying it better . Using functionalities like save , zoom and moving the plots on x and y axis
+{{{ Show solution of self assessment questions slide}}}
+
+ Solution1: We use the command `linspace(-pi/2,pi/2,100)` to create 100 eually spaced lines between the points -pi/2 and pi/2.
+
+ Solution2: We use `clf()` function to clear a figure.
+
+ Solution3: `len(sequence\_name)` is the function used to find out the length of a sequence.
+.. R25
- {{{ Show the "sponsored by FOSSEE" slide }}}
-
+.. L26
-This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India
+ {{{ Show the 'Thankyou' slide }}}
-
- Hope you have enjoyed and found it useful.
+.. R26
- Thankyou
+Hope you have enjoyed and found it useful.
+Thankyou!