# HG changeset patch # User Shantanu # Date 1256238655 -19800 # Node ID fe6a38572a657b5b116331b1879efae7fd94727b # Parent 039a07b0ff5375185f92b3060b5a2d9250fd8bbc Added changes suggested by PR for session 1 day 1. diff -r 039a07b0ff53 -r fe6a38572a65 day1/data/annotate.png Binary file day1/data/annotate.png has changed diff -r 039a07b0ff53 -r fe6a38572a65 day1/data/firstplot.png Binary file day1/data/firstplot.png has changed diff -r 039a07b0ff53 -r fe6a38572a65 day1/data/green.png Binary file day1/data/green.png has changed diff -r 039a07b0ff53 -r fe6a38572a65 day1/data/label.png Binary file day1/data/label.png has changed diff -r 039a07b0ff53 -r fe6a38572a65 day1/data/legend.png Binary file day1/data/legend.png has changed diff -r 039a07b0ff53 -r fe6a38572a65 day1/data/loc.png Binary file day1/data/loc.png has changed diff -r 039a07b0ff53 -r fe6a38572a65 day1/data/title.png Binary file day1/data/title.png has changed diff -r 039a07b0ff53 -r fe6a38572a65 day1/session1.tex --- a/day1/session1.tex Thu Oct 22 18:47:48 2009 +0530 +++ b/day1/session1.tex Fri Oct 23 00:40:55 2009 +0530 @@ -125,51 +125,87 @@ \begin{frame}[fragile] \frametitle{Starting up...} +\begin{block}{} \begin{verbatim} $ ipython -pylab \end{verbatim} -Exiting +\end{block} \begin{lstlisting} In []: print "Hello, World!" - In []: ^D - Do you really want to exit ([y]/n)? y + Hello, World! \end{lstlisting} +Exiting +\begin{lstlisting} + In []: ^D(Ctrl-D) + Do you really want to exit([y]/n)? y +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Loops} Breaking out of loops \begin{lstlisting} In []: while True: ...: print "Hello, World!" ...: Hello, World! - Hello, World!^C + Hello, World!^C(Ctrl-C) \end{lstlisting} \end{frame} \begin{frame}[fragile] \frametitle{First Plot} -\begin{lstlisting} - In []: x = linspace(0, 2*pi, 51) -\end{lstlisting} -\typ{linspace(start, stop, num)} \\ -returns \typ{num} evenly spaced points, in the interval [\typ{start}, \typ{stop}]. +\begin{columns} + \column{0.25\textwidth} + \hspace*{-0.5in} + \includegraphics[height=2in, interpolate=true]{data/firstplot} + \column{0.7\textwidth} + \begin{block}{Code} + \small \begin{lstlisting} - - In []: plot(x,sin(x)) +In []: x=linspace(0,2*pi,51) +In []: plot(x,sin(x)) \end{lstlisting} -\typ{plot(x, y)}\\ + \small + \end{block} +\end{columns} +\end{frame} + + +\begin{frame}[fragile] +\frametitle{Walkthrough} +\begin{block}{\typ{linspace(start, stop, num)} } +returns \typ{num} evenly spaced points, in the interval [\typ{start}, \typ{stop}]. +\end{block} +\vspace*{.5in} +\begin{block}{\typ{plot(x, y)}} plots \typ{x} and \typ{y} using default line style and color +\end{block} \end{frame} \begin{frame}[fragile] \frametitle{Adding Labels} +\begin{columns} + \column{0.25\textwidth} + \hspace*{-0.45in} + \includegraphics[height=2in, interpolate=true]{data/label} + \hspace*{0.5in} + \column{0.55\textwidth} + \begin{block}{} + \small \begin{lstlisting} In []: xlabel('x') - \end{lstlisting} -\typ{xlabel(s)} sets the label of the \typ{x}-axis to \typ{s} - \begin{lstlisting} In []: ylabel('sin(x)') \end{lstlisting} -\typ{ylabel(s)} sets the label of the \typ{y}-axis to \typ{s} + \small +% \end{lstlisting} +%\typ{xlabel(s)} sets the label of the \typ{x}-axis to \typ{s} + +% \begin{lstlisting} + \end{block} +%\typ{ylabel(s)} sets the label of the \typ{y}-axis to \typ{s} +\end{columns} \end{frame} \begin{frame}[fragile] @@ -177,60 +213,75 @@ \begin{lstlisting} In []: clf() In []: y = linspace(0, 2*pi, 51) -In []: plot(y, -2*sin(-y)) +In []: plot(y, sin(2*y)) In []: xlabel('y') -In []: ylabel('-2sin(-y)') +In []: ylabel('sin(2y)') \end{lstlisting} \end{frame} \begin{frame}[fragile] \frametitle{Title and Legends} +\vspace*{-0.15in} +% \begin{block}{} +% \small \begin{lstlisting} In []: title('Sinusoids') #Sets the title of the figure - -In []: legend() -# Shows a legend in the figure -# Used when plot was made with label -# plot(y, -2*sin(-y), label='sin') -In []: legend(['sin']) -# When no labels were used -# Or to change the labels - +In []: legend(['sin(2y)']) +# When no label, or to change \end{lstlisting} +% \small +% \end{block} + \vspace*{-0.1in} + \begin{center} + \includegraphics[height=2in, interpolate=true]{data/legend} + \end{center} \end{frame} \begin{frame}[fragile] \frametitle{Changing Legend Placement} +\vspace*{-0.1in} \begin{lstlisting} -In []: legend(['sin'], loc=5) -#or -In []: legend(['sin'], loc='right') -#or -In []: legend(['sin'], loc=(x,y)) +In []: legend(['sin(2y)'], loc=(0.75,0.1)) #(x,y) is position of lower-left -#corner of legend in the axes co-ords +#corner of legend. \end{lstlisting} +%\vspace*{-0.2in} +\begin{center} + \includegraphics[height=2in, interpolate=true]{data/loc} +\end{center} \end{frame} \begin{frame}[fragile] \frametitle{Changing Legend Placement} -\vspace{-0.15in} +\begin{columns} + \column{0.6\textwidth} +\begin{block}{} + \small +\begin{lstlisting} +In []: legend(['sin(2y)'], + loc='right') +\end{lstlisting} + \small +\end{block} +\column{0.45\textwidth} +\vspace{-0.2in} \begin{lstlisting} -Location String Code -=============== ==== -'best' 0 -'upper right' 1 -'upper left' 2 -'lower left' 3 -'lower right' 4 -'right' 5 -'center left' 6 -'center right' 7 -'lower center' 8 -'upper center' 9 -'center' 10 +Location String +=============== +'best' +'upper right' +'upper left' +'lower left' +'lower right' +'right' +'center left' +'center right' +'lower center' +'upper center' +'center' \end{lstlisting} +\end{columns} \end{frame} @@ -251,12 +302,13 @@ In []: figure(2) In []: plot(x, cos(x)) In []: figure(1) -In []: title('sin(x)')) +In []: title('sin(x)') \end{lstlisting} \end{frame} \begin{frame}[fragile] \frametitle{Showing it better} +\vspace{-0.15in} \begin{lstlisting} In []: plot(y, sin(y), 'g') # plots the curve using green color @@ -264,16 +316,26 @@ In []: plot(y, sin(y), linewidth=2) # sets the linewidth to 2 \end{lstlisting} +\vspace*{-0.2in} +\begin{center} + \includegraphics[height=2in, interpolate=true]{data/green} +\end{center} \end{frame} \begin{frame}[fragile] \frametitle{Annotating} +\vspace*{-0.15in} \begin{lstlisting} -In []: annotate('Sample point', - (50,200)) -# Adds the note 'Sample point' at -# the point (50, 200) +In []: annotate('local max', + xy=(2, 1), + xytext=(3, 1.5), + arrowprops=dict( + shrink=0.05),) \end{lstlisting} +\vspace*{-0.2in} +\begin{center} + \includegraphics[height=2in, interpolate=true]{data/annotate} +\end{center} \end{frame} \begin{frame}[fragile] @@ -284,8 +346,8 @@ In []: ymin, ymax = ylim() #Set the axes limits -In []: xlim( xmin, xmax ) -In []: ylim( ymin, ymax ) +In []: xlim(xmin, xmax) +In []: ylim(ymin, ymax) \end{lstlisting} \end{frame} @@ -297,3 +359,4 @@ \end{frame} \end{document} + diff -r 039a07b0ff53 -r fe6a38572a65 day1/session2.tex --- a/day1/session2.tex Thu Oct 22 18:47:48 2009 +0530 +++ b/day1/session2.tex Fri Oct 23 00:40:55 2009 +0530 @@ -75,7 +75,7 @@ % Title page \title[Basic Python]{Basic Overview\\} -\author[FOSEE Team] {The FOSSEE Group} +\author[FOSSEE Team] {The FOSSEE Group} \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} \date[] {31, October 2009\\Day 1, Session 2} diff -r 039a07b0ff53 -r fe6a38572a65 day2/session1.tex --- a/day2/session1.tex Thu Oct 22 18:47:48 2009 +0530 +++ b/day2/session1.tex Fri Oct 23 00:40:55 2009 +0530 @@ -343,11 +343,11 @@ In []: lst.extend([0, -1, -2]) In []: lst -Out[]: [8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2] +Out[]: [8, 7, 6, 5, 4, 3, 2, 1, 0, -1] In []: lst.remove(0) In []: lst -Out[]: [8, 7, 6, 5, 4, 3, 2, 1, -1, -2] +Out[]: [8, 7, 6, 5, 4, 3, 2, 1, -1] \end{lstlisting} \end{frame} @@ -392,16 +392,16 @@ \frametitle{Dictionaries} \alert {lists and tuples: integer indexes :: dictionaries: string indexes} \begin{lstlisting} -In []: player = {'Mat': 134, 'Inn': 233, 'Runs': 10823, 'Avg': 52.53} +In []: player = {'Mat': 134,'Inn': 233, + 'Runs': 10823, 'Avg': 52.53} In []: player['Avg'] Out[]: 52.530000000000001 - In []: player.keys() Out[]: ['Runs', 'Inn', 'Avg', 'Mat'] - In []: player.values() -Out[]: [10823, 233, 52.530000000000001, 134] +Out[]: [10823, 233, + 52.530000000000001, 134] \end{lstlisting} \end{frame}