|
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
2 % Tutorial slides on Python. |
|
3 % |
|
4 % Author: Prabhu Ramachandran <prabhu at aero.iitb.ac.in> |
|
5 % Copyright (c) 2005-2009, Prabhu Ramachandran |
|
6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
7 |
|
8 \documentclass[14pt,compress]{beamer} |
|
9 %\documentclass[draft]{beamer} |
|
10 %\documentclass[compress,handout]{beamer} |
|
11 %\usepackage{pgfpages} |
|
12 %\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm] |
|
13 |
|
14 % Modified from: generic-ornate-15min-45min.de.tex |
|
15 \mode<presentation> |
|
16 { |
|
17 \usetheme{Warsaw} |
|
18 \useoutertheme{split} |
|
19 \setbeamercovered{transparent} |
|
20 } |
|
21 |
|
22 \usepackage[english]{babel} |
|
23 \usepackage[latin1]{inputenc} |
|
24 %\usepackage{times} |
|
25 \usepackage[T1]{fontenc} |
|
26 |
|
27 % Taken from Fernando's slides. |
|
28 \usepackage{ae,aecompl} |
|
29 \usepackage{mathpazo,courier,euler} |
|
30 \usepackage[scaled=.95]{helvet} |
|
31 |
|
32 \definecolor{darkgreen}{rgb}{0,0.5,0} |
|
33 |
|
34 \usepackage{listings} |
|
35 \lstset{language=Python, |
|
36 basicstyle=\ttfamily\bfseries, |
|
37 commentstyle=\color{red}\itshape, |
|
38 stringstyle=\color{darkgreen}, |
|
39 showstringspaces=false, |
|
40 keywordstyle=\color{blue}\bfseries} |
|
41 |
|
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
43 % Macros |
|
44 \setbeamercolor{emphbar}{bg=blue!20, fg=black} |
|
45 \newcommand{\emphbar}[1] |
|
46 {\begin{beamercolorbox}[rounded=true]{emphbar} |
|
47 {#1} |
|
48 \end{beamercolorbox} |
|
49 } |
|
50 \newcounter{time} |
|
51 \setcounter{time}{0} |
|
52 \newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}} |
|
53 |
|
54 \newcommand{\typ}[1]{\lstinline{#1}} |
|
55 |
|
56 \newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} } |
|
57 |
|
58 %%% This is from Fernando's setup. |
|
59 % \usepackage{color} |
|
60 % \definecolor{orange}{cmyk}{0,0.4,0.8,0.2} |
|
61 % % Use and configure listings package for nicely formatted code |
|
62 % \usepackage{listings} |
|
63 % \lstset{ |
|
64 % language=Python, |
|
65 % basicstyle=\small\ttfamily, |
|
66 % commentstyle=\ttfamily\color{blue}, |
|
67 % stringstyle=\ttfamily\color{orange}, |
|
68 % showstringspaces=false, |
|
69 % breaklines=true, |
|
70 % postbreak = \space\dots |
|
71 % } |
|
72 |
|
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
74 % Title page |
|
75 \title[]{Interactive Plotting} |
|
76 |
|
77 \author[FOSSEE] {FOSSEE} |
|
78 |
|
79 \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} |
|
80 \date[] {31, October 2009} |
|
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
82 |
|
83 %\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} |
|
84 %\logo{\pgfuseimage{iitmlogo}} |
|
85 |
|
86 |
|
87 %% Delete this, if you do not want the table of contents to pop up at |
|
88 %% the beginning of each subsection: |
|
89 \AtBeginSubsection[] |
|
90 { |
|
91 \begin{frame}<beamer> |
|
92 \frametitle{Outline} |
|
93 \tableofcontents[currentsection,currentsubsection] |
|
94 \end{frame} |
|
95 } |
|
96 |
|
97 \AtBeginSection[] |
|
98 { |
|
99 \begin{frame}<beamer> |
|
100 \frametitle{Outline} |
|
101 \tableofcontents[currentsection,currentsubsection] |
|
102 \end{frame} |
|
103 } |
|
104 |
|
105 \newcommand{\num}{\texttt{numpy}} |
|
106 |
|
107 |
|
108 % If you wish to uncover everything in a step-wise fashion, uncomment |
|
109 % the following command: |
|
110 %\beamerdefaultoverlayspecification{<+->} |
|
111 |
|
112 %\includeonlyframes{current,current1,current2,current3,current4,current5,current6} |
|
113 |
|
114 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
115 % DOCUMENT STARTS |
|
116 \begin{document} |
|
117 |
|
118 \begin{frame} |
|
119 \maketitle |
|
120 \end{frame} |
|
121 |
|
122 %% \begin{frame} |
|
123 %% \frametitle{Outline} |
|
124 %% \tableofcontents |
|
125 %% % You might wish to add the option [pausesections] |
|
126 %% \end{frame} |
|
127 |
|
128 |
|
129 \begin{frame}[fragile] |
|
130 \frametitle{Starting up...} |
|
131 \begin{verbatim} |
|
132 $ ipython -pylab |
|
133 \end{verbatim} |
|
134 Exiting |
|
135 \begin{lstlisting} |
|
136 In [1]: print "Hello, World!" |
|
137 In [2]: ^D |
|
138 Do you really want to exit ([y]/n)? y |
|
139 \end{lstlisting} |
|
140 Breaking out of loops |
|
141 \begin{lstlisting} |
|
142 In [1]: while True: |
|
143 ...: print "Hello, World!" |
|
144 ...: |
|
145 Hello, World! |
|
146 Hello, World!^C |
|
147 \end{lstlisting} |
|
148 \end{frame} |
|
149 |
|
150 \begin{frame}[fragile] |
|
151 \frametitle{First Plot} |
|
152 \begin{lstlisting} |
|
153 In [2]: x = linspace(0, 2*pi, 51) |
|
154 \end{lstlisting} |
|
155 \typ{linspace(start, stop, num)} \\ |
|
156 returns \typ{num} evenly spaced points, in the interval [\typ{start}, \typ{stop}]. |
|
157 \begin{lstlisting} |
|
158 |
|
159 In [3]: plot(x,sin(x)) |
|
160 \end{lstlisting} |
|
161 \typ{plot(x, y)}\\ |
|
162 plots \typ{x} and \typ{y} using default line style and color |
|
163 \end{frame} |
|
164 |
|
165 \begin{frame}[fragile] |
|
166 \frametitle{Adding Labels} |
|
167 \begin{lstlisting} |
|
168 In [4]: xlabel('x') |
|
169 \end{lstlisting} |
|
170 \typ{xlabel(s)} sets the label of the \typ{x}-axis to \typ{s} |
|
171 |
|
172 \begin{lstlisting} |
|
173 In [5]: ylabel('sin(x)') |
|
174 \end{lstlisting} |
|
175 \typ{ylabel(s)} sets the label of the \typ{y}-axis to \typ{s} |
|
176 \end{frame} |
|
177 |
|
178 \begin{frame}[fragile] |
|
179 \frametitle{Another example} |
|
180 \begin{lstlisting} |
|
181 In [6]: clf() |
|
182 |
|
183 In [7]: y = linspace(0, 2*pi, 51) |
|
184 |
|
185 In [8]: plot(y, -2*sin(-y)) |
|
186 |
|
187 In [9]: xlabel('y') |
|
188 |
|
189 In [10]: ylabel('-2sin(-y)') |
|
190 \end{lstlisting} |
|
191 \end{frame} |
|
192 |
|
193 \begin{frame}[fragile] |
|
194 \frametitle{Title and Legends} |
|
195 \begin{lstlisting} |
|
196 In [11]: title('Sinusoids') |
|
197 |
|
198 In [12]: legend(['-2sin(-y)']) |
|
199 \end{lstlisting} |
|
200 \end{frame} |
|
201 |
|
202 \begin{frame}[fragile] |
|
203 \frametitle{Saving \& Closing} |
|
204 \begin{lstlisting} |
|
205 In [13]: savefig('2siny.png') |
|
206 |
|
207 In [14]: close() |
|
208 \end{lstlisting} |
|
209 \end{frame} |
|
210 |
|
211 \begin{frame}[fragile] |
|
212 \frametitle{Multiple Figures} |
|
213 \begin{lstlisting} |
|
214 In []: figure(1) |
|
215 In []: plot(x, sin(x)) |
|
216 In []: figure(2) |
|
217 In []: plot(x, cos(x)) |
|
218 In []: figure(1) |
|
219 In []: title('sin(x)')) |
|
220 \end{lstlisting} |
|
221 \end{frame} |
|
222 |
|
223 \begin{frame}[fragile] |
|
224 \frametitle{Showing it better} |
|
225 \begin{lstlisting} |
|
226 In []: plot(y, sin(y), 'g') |
|
227 In []: plot(y, sin(y), linewidth=2) |
|
228 \end{lstlisting} |
|
229 \end{frame} |
|
230 |
|
231 \begin{frame}[fragile] |
|
232 \frametitle{Axes lengths} |
|
233 \begin{lstlisting} |
|
234 #Get the limits |
|
235 In []: xmin, xmax = xlim() |
|
236 In []: ymin, ymax = ylim() |
|
237 |
|
238 #Set the limits |
|
239 In []: xlim( xmin, xmax ) |
|
240 In []: ylim( ymin, ymax ) |
|
241 \end{lstlisting} |
|
242 \end{frame} |
|
243 |
|
244 \begin{frame}[fragile] |
|
245 \begin{center} |
|
246 End of Session-1\\ |
|
247 \alert{Don't Close \typ{IPython}} |
|
248 \end{center} |
|
249 \end{frame} |
|
250 |
|
251 \end{document} |