diff options
Diffstat (limited to 'using_plot_interactively')
-rw-r--r-- | using_plot_interactively/oldscript.rst | 226 | ||||
-rw-r--r-- | using_plot_interactively/script.rst | 81 | ||||
-rw-r--r-- | using_plot_interactively/slides.org | 5 | ||||
-rw-r--r-- | using_plot_interactively/slides.tex | 108 |
4 files changed, 350 insertions, 70 deletions
diff --git a/using_plot_interactively/oldscript.rst b/using_plot_interactively/oldscript.rst new file mode 100644 index 0000000..cd2ee6a --- /dev/null +++ b/using_plot_interactively/oldscript.rst @@ -0,0 +1,226 @@ +.. Objectives +.. ---------- + +.. By the end of this tutorial you will -- + +.. 1. Create simple plots of mathematical functions +.. #. Use the Figure window to study plots better + + + +.. Prerequisites +.. ------------- + +.. Installation of required tools +.. Ipython + +.. Author : Amit Sethi + Internal Reviewer : + External Reviewer : + Checklist OK? : <put date stamp here, if OK> [2010-10-05] + +Script +------- +{{{ Show the Title Slide }}} + +Hello and welcome to the tutorial on creating simple plots using +Python.This tutorial is presented by the Fossee group. + +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. + +{{{ Show Outline Slide }}} + +Lets start ipython on your shell, type :: + + $ipython -pylab + + +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 :: + + + `ERROR: matplotlib could NOT be imported! Starting normal + IPython.` + + +{{{ Slide with Error written on it }}} + + +Then you have to install matplotlib and run this command again. + +Now type in your ipython shell :: + + linpace? + + + +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. :: + + linspace(1,100,100) + +As you can see a sequence of numbers from 1 to 100 appears. + +Now lets try 200 points between 0 and 1 you do this by typing :: + + + 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) + + +'pi' here is constant defined by pylab. Save this to the variable, p +. + +If you now :: + + len(p) + +You will get the no. of points. len function gives the no of elements +of a sequence. + + +Let's try and plot a cosine curve between -pi and pi using these +points. Simply type:: + + plot(p,cos(points)) + + +Here cos(points) gets the cosine value at every corresponding point to +p. + + +We can also save cos(points) to variable cosine and plot it using +plot.:: + + cosine=cos(points) + + plot(p,cosine) + + + +Now do :: + + clf() + +this will clear the plot. + +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. :: + + + plot(p,sin(p)) + + + + +The Window on which the plot appears can be used to study it better. + +{{{ Show the slide with all the buttons on it }}} + +First of all moving the mouse around gives us the point where mouse +points at. + +Also we have some buttons the right most among them is +for saving the file. + +Just click on it specifying the name of the file. We will save the plot +by the name sin_curve in pdf format. + + + +{{{ Show how to save the file }}} + +As you can see I can specify format of file from the dropdown. + +Formats like png ,eps ,pdf, ps are available. + +Left to the save button is the slider button to specify the margins. + +{{{ 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 +region to zoom into. + +{{{ Press Move button and move the axes. }}} + +The button left to it can be used to move the axes of the plot. + +{{{ 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. + +{{{ Press home button }}} + +The last one is 'home' referring to the initial plot. + + + + +Following is an exercise that you must do. + +%% %% 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. + + +Please, pause the video here. Do the exercise and then continue. + + + + + + + + + +{{{ Summary Slide }}} + +In this tutorial we have looked at + +1. Starting Ipython with pylab + +2. Using linspace function to create `num` equaly spaced points in a region. + +3. Finding length of sequnces using len. + +4. Plotting mathematical functions using plot. + +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 the "sponsored by FOSSEE" slide }}} + + + +This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India + + + + Hope you have enjoyed and found it useful. + + Thankyou + + + +Author : Amit Sethi +Internal Reviewer : +Internal Reviewer 2 : 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 diff --git a/using_plot_interactively/slides.org b/using_plot_interactively/slides.org index 73a638d..ab82eec 100644 --- a/using_plot_interactively/slides.org +++ b/using_plot_interactively/slides.org @@ -62,6 +62,11 @@ MHRD, Govt. of India - Back and Forward Button - Home +* Question1 + 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. * Summary In this tutorial,we have learnt to- diff --git a/using_plot_interactively/slides.tex b/using_plot_interactively/slides.tex index 2e1d36b..ade4ff6 100644 --- a/using_plot_interactively/slides.tex +++ b/using_plot_interactively/slides.tex @@ -1,4 +1,4 @@ -% Created 2010-11-11 Thu 13:15 +% Created 2011-05-04 Wed 11:44 \documentclass[presentation]{beamer} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} @@ -8,7 +8,6 @@ \usepackage{float} \usepackage{wrapfig} \usepackage{soul} -\usepackage{t1enc} \usepackage{textcomp} \usepackage{marvosym} \usepackage{wasysym} @@ -24,14 +23,14 @@ commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen}, showstringspaces=false, keywordstyle=\color{blue}\bfseries} \providecommand{\alert}[1]{\textbf{#1}} -\title{Using Plot Interactively} +\title{} \author{FOSSEE} \date{} \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent} \begin{document} -\maketitle + @@ -42,26 +41,44 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries} \begin{frame} -\frametitle{Outline} -\label{sec-1} - How to plot a simple mathematical function. - Using the User Interface of plot figure. +\begin{center} +\textcolor{blue}{Using plot Interactively} +\end{center} +\begin{center} +\includegraphics[scale=0.25]{../images/iitb-logo.png}\\ +Developed by FOSSEE Team, IIT-Bombay. \\ +Funded by National Mission on Education through ICT + +MHRD, Govt. of India +\end{center} \end{frame} \begin{frame} -\frametitle{Error if Ipython not installed} +\frametitle{Objectives} \label{sec-2} + + At the end of this tutorial, you will be able to, + +\begin{itemize} +\item Create simple plots of mathematical functions. +\item Use the Figure window to study plots better. +\end{itemize} +\end{frame} +\begin{frame} +\frametitle{Error if Ipython not installed} +\label{sec-3} \begin{itemize} \item `ERROR: matplotlib could NOT be imported! Starting normal IPython.`\\ -\label{sec-2_1}% +\label{sec-3_1}% \end{itemize} % ends low level \end{frame} \begin{frame} \frametitle{Plot UI} -\label{sec-3} +\label{sec-4} \includegraphics[height=0.12in, interpolate=true]{buttons} + \begin{itemize} \item Save \item Zoom @@ -69,31 +86,80 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries} \item Back and Forward Button \item Home \end{itemize} +\end{frame} +\begin{frame} +\frametitle{Question1} +\label{sec-5} + Plot (sin(x)*sin(x))/x. - +\begin{enumerate} +\item Save the plot by the sinsquarebyx.pdf in pdf format. +\item Zoom and find the maxima. +\item Bring it back to initial position. +\end{enumerate} \end{frame} \begin{frame} \frametitle{Summary} -\label{sec-4} +\label{sec-6} -\begin{itemize} -\item Plotting mathematical functions using plot. - \includegraphics[height=0.12in, interpolate=true]{buttons} -\item Using the UI of plot + In this tutorial,we have learnt to- \begin{itemize} +\item Start Ipython with pylab. +\item Use the linspace function to create `num` equally spaced points in a region. +\item Find the length of sequnces using len function. +\item Plot mathematical functions using plot. +\item Clear drawing area using clf. +\item Plott mathematical functions using plot. +\item Use the UI of plot +\begin{itemize} \item Save \item Zoom \item Move axis \item Back and Forward Button \item Home \end{itemize} - \end{itemize} + +\end{frame} +\begin{frame} +\frametitle{Evaluation} +\label{sec-7} - - + +\begin{enumerate} +\item Create 100 equally spaced points between -pi/2 and pi/2? +\item How do you clear a figure in ipython? +\item How do find the length of a sequen +\end{enumerate} +\end{frame} +\begin{frame} +\frametitle{Solutions\ldots{}} +\label{sec-8} + + +\begin{enumerate} +\item linspace(-pi/2,pi/2,100) +\item clf() +\item len(sequence\_name) +\end{enumerate} +\end{frame} +\begin{frame} +\frametitle{Acknowledgement\ldots{}} +\label{sec-9} + + \begin{block}{} + \begin{center} + \textcolor{blue}{\Large THANK YOU!} + \end{center} + \end{block} +\begin{block}{} + \begin{center} + For more Information, visit our website\\ + \url{http://fossee.in/} + \end{center} + \end{block} \end{frame} -\end{document} +\end{document}
\ No newline at end of file |