diff options
author | Jovina | 2011-05-04 12:05:01 +0530 |
---|---|---|
committer | Jovina | 2011-05-04 12:05:01 +0530 |
commit | 8f769af90d747f7e12e4ef64ec2ee9dabf19b727 (patch) | |
tree | 23b5de3ab7c201220de16da2fcbaf6a54e128a0f /using_plot_interactively/script.rst | |
parent | 19c8f29fa0be1c8697078fbeae780c5aa52b0676 (diff) | |
download | st-scripts-8f769af90d747f7e12e4ef64ec2ee9dabf19b727.tar.gz st-scripts-8f769af90d747f7e12e4ef64ec2ee9dabf19b727.tar.bz2 st-scripts-8f769af90d747f7e12e4ef64ec2ee9dabf19b727.zip |
Modified files in module1.
Diffstat (limited to 'using_plot_interactively/script.rst')
-rw-r--r-- | using_plot_interactively/script.rst | 81 |
1 files changed, 32 insertions, 49 deletions
diff --git a/using_plot_interactively/script.rst b/using_plot_interactively/script.rst index 5de2c30..00e203a 100644 --- a/using_plot_interactively/script.rst +++ b/using_plot_interactively/script.rst @@ -4,7 +4,7 @@ .. By the end of this tutorial you will -- .. 1. Create simple plots of mathematical functions -.. 2. Use features of graphical window to manipulate plots +.. #. Use the Figure window to study plots better @@ -30,26 +30,22 @@ team along with the logo of MHRD }}} Hello Friends and welcome to the tutorial on creating simple plots using iPython. -I hope you have IPython installed on your computer if not, then refer to the spoken tutorial -on instaling ipython. +I hope you have IPython running on your computer. .. L2 {{{ Show Objective Slide }}} -At the end of this tutorial, you will be able to, - - 1. Create simple plots of mathematical functions. - 2. Use features of graphical window to manipulate plots - - .. R2 +At the end of this tutorial, you will be able to, + 1. Create simple plots of mathematical functions. + #. Use the Figure window to study plots better. .. R3 -To start ipython, Open the terminal and type +Lets start ipython.Open the terminal and type ipython -pylab and hit enter. .. L3 @@ -62,31 +58,21 @@ ipython -pylab and hit enter. Pylab is a python library which provides plotting functionality.It provides many other important mathematical and scientific -functions. -After running IPython -pylab in your shell, -the screen will look like this. - -.. Pause the video for 2 sec then continue. - -But instead if you get the following error like:: - -- show the error slide +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. -.. Add some instruction to help user to install matplotlib. - .. L4 {{{ Slide with Error written on it }}} .. R5 -To get array of numbers we use linspace command. -Type 'linspace' followed by a '?' mark to get detailed documentation/help of it +Now type 'linspace' followed by a '?' mark in your ipython shell .. L5 @@ -96,9 +82,10 @@ Type 'linspace' followed by a '?' mark to get detailed documentation/help of it .. R6 -As the documentation says, it returns `num` evenly spaced samples, +as the documentation says, it returns `num` evenly spaced samples, calculated over the interval start and stop. To illustrate this, lets 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. .. L6 @@ -106,11 +93,9 @@ try to generate 100 points.Type ``linspace(1,100,100)`` and hit enter. linspace(1,100,100) -As you can see a sequence of numbers from 1 to 100 appears. - .. R7 -To generate 200 points between 0 and 1, type linspace(0,1,200). +Now lets try to generate 200 points between 0 and 1,we do that by typing linspace(0,1,200). .. L7 @@ -120,10 +105,10 @@ To generate 200 points between 0 and 1, type linspace(0,1,200). .. R8 -Here,0 is the start , 1 is the stop and 200 is the number of points. In linspace +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. -To get 100 points between -pi to pi where 'pi' is a constant -defined by pylab and save the result to the variable,say p. Type p=linspace(-pi,pi,100). +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 @@ -133,7 +118,8 @@ defined by pylab and save the result to the variable,say p. Type p=linspace(-pi, .. R9 -To get the number of elements or points of a sequence say p type ''len(p)'' +If we now type ``len(p)``we will get the no. of points. +``len`` function gives the no of elements of a sequence. .. L9 @@ -144,7 +130,7 @@ To get the number of elements or points of a sequence say p type ''len(p)'' .. R10 -To plot a cosine curve between -pi and pi, we use the plot command. +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. @@ -168,7 +154,7 @@ plot function. .. R12 -To clear the plot, use the ``clf()`` function +Now to clear the plot ,we use the ``clf()`` function .. L12 @@ -178,9 +164,8 @@ To clear the plot, use the ``clf()`` function .. R13 -If the plot is not cleared, then any new plot will overlap the previous plot. Hence to avoid -cluttering the area with overlaid plots use clf() function. - +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 @@ -191,16 +176,15 @@ Now lets try a sine plot. .. R14 -We can manipulate the plot in the graphical window. +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. .. L14 -{{{ Show the slide with all the buttons on it }}} +{{{ Show the slide 'Plot UI' }}} .. R15 -The location of the mouse pointer on the window is displayed in bottom right corner of the window. -By moving the mouse pointer the location of each point is seen. +As we can observe, moving the mouse pointer along the plot gives us the location of each point on the plot .. L15 @@ -210,9 +194,9 @@ By moving the mouse pointer the location of each point is seen. 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 in the box provided. We will save the plot +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 also available. +of file from the dropdown.Formats like png ,eps ,pdf, ps are available. .. L16 @@ -267,8 +251,7 @@ The last one is 'home' referring to the initial plot. .. R22 -Pause the video and do this exercise. Resume the video once done. - +Pause the video here, try out the following exercise and resume the video. Plot (sin(x)*sin(x))/x. @@ -278,7 +261,7 @@ Pause the video and do this exercise. Resume the video once done. .. L23 -{{{ Summary Slide }}} +{{{ Switch to the Summary Slide }}} .. R23 @@ -287,9 +270,9 @@ Let's revise quickly what we have learnt today 1. To Start Ipython with pylab. #. To Use the linspace function to create `num` equally spaced points in a region. #. To Find the length of sequnces using len function. - #. To Plot mathematical functions using plot function. - #. To Clear drawing area using clf function. - #. Manipulate the plot in the window itself by using functionalities like save, zoom, move, home, arrow buttons. + #. To Plot mathematical functions using plot. + #. To Clear drawing area using clf. + #. 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 @@ -315,7 +298,7 @@ And the answers, 2. We use `clf()` function to clear a figure. -3. `len(sequence\_name)` is the function used to find out the length of a sequence. +3. `len(sequence_name)` is the function used to find out the length of a sequence. .. L26 |