day1/session1.tex
changeset 143 5d0444e9788a
parent 141 fccf675946bf
child 147 6874a667dc4e
equal deleted inserted replaced
142:57e0f0fd3317 143:5d0444e9788a
   148   In []: while True:
   148   In []: while True:
   149     ...:     print "Hello, World!"
   149     ...:     print "Hello, World!"
   150     ...:     
   150     ...:     
   151   Hello, World!
   151   Hello, World!
   152   Hello, World!^C(Ctrl-C)
   152   Hello, World!^C(Ctrl-C)
       
   153   ------------------------------------
       
   154   KeyboardInterrupt                   
       
   155 
   153 \end{lstlisting}
   156 \end{lstlisting}
   154 \end{frame}
   157 \end{frame}
   155 
   158 
   156 \begin{frame}[fragile]
   159 \begin{frame}[fragile]
   157 \frametitle{First Plot}
   160 \frametitle{First Plot}
   158 \begin{columns}
   161 \begin{columns}
   159     \column{0.25\textwidth}
   162     \column{0.25\textwidth}
   160     \hspace*{-0.5in}
   163     \hspace*{-0.5in}
   161   \includegraphics[height=2in, interpolate=true]{data/firstplot}  
   164   \includegraphics[height=2in, interpolate=true]{data/firstplot}  
   162     \column{0.7\textwidth}
   165     \column{0.8\textwidth}
   163     \begin{block}{Code}
   166     \begin{block}{}
   164     \small
   167     \small
   165 \begin{lstlisting}
   168 \begin{lstlisting}
   166 In []: x=linspace(0,2*pi,51)
   169 In []: x = linspace(0, 2*pi, 51)
   167 In []: plot(x,sin(x))
   170 In []: plot(x, sin(x))
   168 \end{lstlisting}
   171 \end{lstlisting}
   169     \small
   172     \small
   170     \end{block}
   173     \end{block}
   171 \end{columns}
   174 \end{columns}
   172 \end{frame}
   175 \end{frame}
   240 
   243 
   241 \begin{frame}[fragile]
   244 \begin{frame}[fragile]
   242 \frametitle{Changing Legend Placement}
   245 \frametitle{Changing Legend Placement}
   243 \vspace*{-0.1in}
   246 \vspace*{-0.1in}
   244 \begin{lstlisting}
   247 \begin{lstlisting}
   245 In []: legend(['sin(2y)'], loc=(0.75,0.1)) 
   248 In []: legend(['sin(2y)'], loc=(.8,.1)) 
   246 #(x,y) is position of lower-left 
   249 #(x,y) is position of lower-left 
   247 #corner of legend.
   250 #corner of legend box.
   248 \end{lstlisting}
   251 \end{lstlisting}
   249 %\vspace*{-0.2in}
   252 %\vspace*{-0.2in}
   250 \begin{center}
   253 \begin{center}
   251   \includegraphics[height=2in, interpolate=true]{data/loc}  
   254   \includegraphics[height=2in, interpolate=true]{data/loc}  
   252 \end{center}
   255 \end{center}
   296 
   299 
   297 \begin{frame}[fragile]
   300 \begin{frame}[fragile]
   298 \frametitle{Multiple Figures}
   301 \frametitle{Multiple Figures}
   299 \begin{lstlisting}
   302 \begin{lstlisting}
   300 In []: figure(1)
   303 In []: figure(1)
   301 In []: plot(x, sin(x))
   304 In []: plot(y, sin(y))
   302 In []: figure(2)
   305 In []: figure(2)
   303 In []: plot(x, cos(x))
   306 In []: plot(y, cos(y))
   304 In []: figure(1)
   307 In []: figure(1)
   305 In []: title('sin(x)')
   308 In []: title('sin(y)')
       
   309 In []: close()
       
   310 In []: close()
   306 \end{lstlisting}
   311 \end{lstlisting}
   307 \end{frame}
   312 \end{frame}
   308 
   313 
   309 \begin{frame}[fragile]
   314 \begin{frame}[fragile]
   310 \frametitle{Showing it better}
   315 \frametitle{Showing it better}
   311 \vspace{-0.15in}
   316 \vspace{-0.15in}
   312 \begin{lstlisting}
   317 \begin{lstlisting}
   313 In []: plot(y, sin(y), 'g')
   318 In []: plot(y, sin(y), 'g')
   314 # plots the curve using green color
   319 
   315 
   320 In []: clf()
   316 In []: plot(y, sin(y), linewidth=2)
   321 In []: plot(y, sin(y), linewidth=2)
   317 # sets the linewidth to 2  
       
   318 \end{lstlisting}
   322 \end{lstlisting}
   319 \vspace*{-0.2in}
   323 \vspace*{-0.2in}
   320 \begin{center}
   324 \begin{center}
   321   \includegraphics[height=2in, interpolate=true]{data/green}  
   325   \includegraphics[height=2.2in, interpolate=true]{data/green}  
   322 \end{center}
   326 \end{center}
   323 \end{frame}
   327 \end{frame}
   324 
   328 
   325 \begin{frame}[fragile]
   329 \begin{frame}[fragile]
   326 \frametitle{Annotating}
   330 \frametitle{Annotating}
   327 \vspace*{-0.15in}
   331 \vspace*{-0.15in}
   328 \begin{lstlisting}
   332 \begin{lstlisting}
   329 In []: annotate('local max', 
   333 In []: annotate('local max', 
   330        xy=(2, 1), 
   334        xy=(1.5, 1), 
   331        xytext=(3, 1.5),
   335        xytext=(2.5, .8),
   332        arrowprops=dict(
   336        arrowprops=dict(
   333        shrink=0.05),)
   337        shrink=0.05),)
   334 \end{lstlisting}
   338 \end{lstlisting}
   335 \vspace*{-0.2in}
   339 \vspace*{-0.2in}
   336 \begin{center}
   340 \begin{center}
   343   \begin{lstlisting}
   347   \begin{lstlisting}
   344 #Get the axes limits
   348 #Get the axes limits
   345 In []: xmin, xmax = xlim() 
   349 In []: xmin, xmax = xlim() 
   346 In []: ymin, ymax = ylim() 
   350 In []: ymin, ymax = ylim() 
   347 
   351 
       
   352 In []: xmax = 2*pi
   348 #Set the axes limits
   353 #Set the axes limits
   349 In []: xlim(xmin, xmax) 
   354 In []: xlim(xmin, xmax) 
   350 In []: ylim(ymin, ymax) 
   355 In []: ylim(ymin, ymax) 
   351   \end{lstlisting}
   356   \end{lstlisting}
   352 \end{frame}
   357 \end{frame}