# HG changeset patch # User Puneeth Chaganti # Date 1289280293 -19800 # Node ID 43a24f7ab18316ef73d7b4dd894afc5bba51e19c # Parent 8f4c369a41f1a0b312a26db0e5319a744b56025d Moved plotui to using-plot-interactively. diff -r 8f4c369a41f1 -r 43a24f7ab183 using-plot-interactively/buttons.png Binary file using-plot-interactively/buttons.png has changed diff -r 8f4c369a41f1 -r 43a24f7ab183 using-plot-interactively/move.png Binary file using-plot-interactively/move.png has changed diff -r 8f4c369a41f1 -r 43a24f7ab183 using-plot-interactively/questions.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/using-plot-interactively/questions.rst Tue Nov 09 10:54:53 2010 +0530 @@ -0,0 +1,51 @@ +Objective Questions +------------------- + +.. A mininum of 8 questions here (along with answers) + +1. Create 100 equally spaced points between -pi/2 and pi/2? + + Answer: linspace(-pi/2,pi/2,100) + +2. How do you clear a figure in ipython? + + Answer: clf() + +3. How do find the length of a sequence? + + Answer: len(sequence_name) + +4. Create a plot of x and e^x where x is 100 equally spaced points between 0,pi. Hint: e^x -> exp(x) for ipython + + Answer: x=linspace(0,pi,100) + plot(x,exp(x)) + +5. List four formats in which you can save a plot in ipython? + + Answer: png,eps,pdf,ps + +6. List the kind of buttons available in plotui to study the plot better ? + + Zoom button to Zoom In to a region. + Pan button to move it around. + +7. What are the left and right arrow buttons for? + + Answer: These buttons take you to the states that the plot has been. Much like a browser left and right arrow button. + + + +8. What is the home button for in the Plot UI? + + Initial State of the plot. + + + + +Larger Questions +---------------- + +.. A minimum of 2 questions here (along with answers) + +1. Use '?' and explain the similarities and difference between linpace and logspace? +2. Describe one by one all the buttons in UI of plot and their meaning? diff -r 8f4c369a41f1 -r 43a24f7ab183 using-plot-interactively/quickref.tex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/using-plot-interactively/quickref.tex Tue Nov 09 10:54:53 2010 +0530 @@ -0,0 +1,14 @@ +Creating a linear array:\\ +{\ex \lstinline| x = linspace(0, 2*pi, 50)|} + +Plotting two variables:\\ +{\ex \lstinline| plot(x, sin(x))|} + +Saving Plot\\ +{\includegraphics[width=60mm]{save.png}} + +Zooming into a part of the plot\\ +{\includegraphics[width=60mm]{zoom.png}} + +Move the plot\\ +{\includegraphics[width=60mm]{move.png}} diff -r 8f4c369a41f1 -r 43a24f7ab183 using-plot-interactively/save.png Binary file using-plot-interactively/save.png has changed diff -r 8f4c369a41f1 -r 43a24f7ab183 using-plot-interactively/script.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/using-plot-interactively/script.rst Tue Nov 09 10:54:53 2010 +0530 @@ -0,0 +1,212 @@ +.. 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? : [2010-10-05] + +Script +------- + + +Hello and welcome to the tutorial on creating simple plots using +Python.This tutorial is presented by the Fossee group. +{{{ Show the Title Slide }}} + +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 :: + + In[]: 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. :: + + In[]: 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 :: + + + In[]: 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 :: + + In[]: p = linspace(-pi,pi,100) + + +'pi' here is constant defined by pylab. Save this to the variable, p +. + +If you now :: + + In[]: 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 :: + + + In[]: 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.:: + + In[]: cosine=cos(points) + + In[]: plot(p,cosine) + + + +Now do :: + + In[]: 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. :: + + + In []: 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. + + + +{{{ Action corelating with the words }}} + +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. + +{{{ Action corelating with the words }}} + +Left to this is zoom button to zoom into the plot. Just specify the +region to zoom into. +The button left to it can be used to move the axes of the plot. + +{{{ Action corelating with the words }}} + +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. + +{{{ Action corelating with the words }}} + +The last one is 'home' referring to the initial plot. + +{{{ Action corelating with the words}}} + + + +{{{ 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 -r 8f4c369a41f1 -r 43a24f7ab183 using-plot-interactively/slides.tex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/using-plot-interactively/slides.tex Tue Nov 09 10:54:53 2010 +0530 @@ -0,0 +1,71 @@ +% Created 2010-10-20 Wed 21:57 +\documentclass[presentation]{beamer} +\usetheme{Warsaw}\useoutertheme{infolines}\usecolortheme{default}\setbeamercovered{transparent} +\usepackage[latin1]{inputenc} +\usepackage[T1]{fontenc} +\usepackage{graphicx} +\usepackage{longtable} +\usepackage{float} +\usepackage{wrapfig} +\usepackage{soul} +\usepackage{amssymb} +\usepackage{hyperref} + + +\title{Plotting Data } +\author{FOSSEE} +\date{2010-09-14 Tue} + +\begin{document} + +\maketitle + +\begin{frame} +\frametitle{Tutorial Plan} +\label{sec-1} +\begin{itemize} + +\item Creating a simple plot\\ +\label{sec-1.1}% +\item Use the buttons on window to study the plot\\ +\label{sec-1.2}% +\end{itemize} % ends low level +\end{frame} +\begin{frame} +\frametitle{Error if Ipython not installed} +\label{sec-2} +\begin{itemize} + +\item `ERROR: matplotlib could NOT be imported! Starting normal IPython.`\\ +\label{sec-2.1}% +\end{itemize} % ends low level +\end{frame} +\begin{frame} +\frametitle{Plot UI} +\label{sec-3} +\begin{frame} + \begin{center} + \includegraphics[height=1.0in,width=4.2in]{buttons.png} + \end{center} +\end{frame} + +\frametitle{Summary} +\label{sec-4} +\begin{itemize} + +\item Start Ipython with pylab\\ +\label{sec-4.1}% +\item Using linspace\\ +\label{sec-4.2}% +\item Finding length of sequnces using len.\\ +\label{sec-4.3}% +\item Plotting mathematical functions using plot.\\ +\label{sec-4.4}% +\item Clearing drawing area using clf\\ +\label{sec-4.5}% +\item Using the UI of plot\\ +\label{sec-4.6}% +\end{itemize} % ends low level +\end{frame} + +\end{document} diff -r 8f4c369a41f1 -r 43a24f7ab183 using-plot-interactively/zoom.png Binary file using-plot-interactively/zoom.png has changed