1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2 %Tutorial slides on Python. |
2 %Tutorial slides on Python. |
3 % |
3 % |
4 % Author: The FOSSEE Group |
4 % Author: FOSSEE |
5 % Copyright (c) 2009, The FOSSEE Group, IIT Bombay |
5 % Copyright (c) 2009, FOSSEE, IIT Bombay |
6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
7 |
7 |
8 \documentclass[14pt,compress]{beamer} |
8 \documentclass[14pt,compress]{beamer} |
9 %\documentclass[draft]{beamer} |
9 %\documentclass[draft]{beamer} |
10 %\documentclass[compress,handout]{beamer} |
10 %\documentclass[compress,handout]{beamer} |
73 |
73 |
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
75 % Title page |
75 % Title page |
76 \title[Plotting using Python]{Plotting experimental data\\} |
76 \title[Plotting using Python]{Plotting experimental data\\} |
77 |
77 |
78 \author[FOSSEE Team] {The FOSSEE Group} |
78 \author[FOSSEE] {FOSSEE} |
79 |
79 |
80 \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} |
80 \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} |
81 \date[] {31, October 2009\\Day 1, Session 2} |
81 \date[] {31, October 2009\\Day 1, Session 2} |
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
83 |
83 |
146 \begin{itemize} |
146 \begin{itemize} |
147 \item run the file in IPython using \typ{\%run first_plot.py}\\ |
147 \item run the file in IPython using \typ{\%run first_plot.py}\\ |
148 \end{itemize} |
148 \end{itemize} |
149 \end{frame} |
149 \end{frame} |
150 |
150 |
|
151 \section{Plotting Points} |
|
152 \begin{frame}[fragile] |
|
153 \frametitle{Simple Pendulum - L and T} |
|
154 \begin{itemize} |
|
155 \item Given data of Length and Time-period of a Simple pendulum |
|
156 \item We wish to plot L vs. \alert{$T^2$} |
|
157 \end{itemize} |
|
158 \begin{lstlisting} |
|
159 In []: L = [0.1, 0.2, 0.3, |
|
160 0.4, 0.5, 0.6, |
|
161 0.7, 0.8, 0.9] |
|
162 In []: T = [0.6529, 0.8485, 1.0590, |
|
163 1.2390, 1.4124, 1.5061, |
|
164 1.6441, 1.7949, 1.8758] |
|
165 \end{lstlisting} |
|
166 \end{frame} |
|
167 |
|
168 \begin{frame}[fragile] |
|
169 \frametitle{Simple Pendulum \ldots} |
|
170 \begin{itemize} |
|
171 \item Let us begin with $L$ vs. \alert{$T$} |
|
172 \end{itemize} |
|
173 \begin{lstlisting} |
|
174 In []: plot(L, T) |
|
175 \end{lstlisting} |
|
176 \begin{itemize} |
|
177 \item But we wish to plot points! |
|
178 \end{itemize} |
|
179 \end{frame} |
|
180 |
|
181 \begin{frame}[fragile] |
|
182 \frametitle{Plotting points} |
|
183 \begin{lstlisting} |
|
184 In []: clf() |
|
185 |
|
186 In []: plot(L, T, 'o') |
|
187 Out[]: [<matplotlib.lines.Line2D object at 0xac17e0c>] |
|
188 |
|
189 In []: clf() |
|
190 In []: plot(L, T, '.') |
|
191 Out[]: [<matplotlib.lines.Line2D object at 0xac17e0c>] |
|
192 \end{lstlisting} |
|
193 \end{frame} |
|
194 |
|
195 \begin{frame}[fragile] |
|
196 \frametitle{Plotting Attributes} |
|
197 \begin{itemize} |
|
198 \item \kwrd{'o'} - Dots |
|
199 \item \kwrd{'-'} - Lines |
|
200 \item \kwrd{'- -'} - Dashed lines |
|
201 \end{itemize} |
|
202 \end{frame} |
|
203 |
|
204 |
|
205 |
151 \section{File Handling} |
206 \section{File Handling} |
152 \begin{frame}[fragile] |
207 \begin{frame}[fragile] |
153 \frametitle{File and \kwrd{for}} |
208 \frametitle{File and \kwrd{for}} |
154 \begin{lstlisting} |
209 \begin{lstlisting} |
155 In []: f = open('dummyfile') |
210 In []: f = open('dummyfile') |
182 \end{lstlisting} |
237 \end{lstlisting} |
183 \inctime{5} |
238 \inctime{5} |
184 \end{frame} |
239 \end{frame} |
185 |
240 |
186 \section{Plotting points} |
241 \section{Plotting points} |
187 \begin{frame}[fragile] |
|
188 \frametitle{How to plot points?} |
|
189 \begin{lstlisting} |
|
190 In []: plt.plot(x, sin(x), 'ro') |
|
191 Out[]: [<matplotlib.lines.Line2D object at 0xac17e0c>] |
|
192 \end{lstlisting} |
|
193 \begin{itemize} |
|
194 \item \kwrd{'r'},\kwrd{'g'},\kwrd{'b'} for red, green and blue |
|
195 \item \kwrd{'o'} - Dots |
|
196 \item \kwrd{'-'} - Lines |
|
197 \item \kwrd{'- -'} - Dashed lines |
|
198 \end{itemize} |
|
199 \inctime{5} |
|
200 \end{frame} |
|
201 |
242 |
202 \section{Lists} |
243 \section{Lists} |
203 |
244 |
204 \begin{frame}[fragile] |
245 \begin{frame}[fragile] |
205 \frametitle{List creation and indexing} |
246 \frametitle{List creation and indexing} |