day2/session1.tex
changeset 10 84c3f600045f
parent 9 2281002b579b
parent 8 41bdf277c755
child 12 996fb264fbe2
equal deleted inserted replaced
9:2281002b579b 10:84c3f600045f
   220     \typ{less (<)}, \typ{greater (>)} etc.
   220     \typ{less (<)}, \typ{greater (>)} etc.
   221   \item Trig and other functions: \typ{sin(x), arcsin(x), sinh(x),
   221   \item Trig and other functions: \typ{sin(x), arcsin(x), sinh(x),
   222       exp(x), sqrt(x)} etc.
   222       exp(x), sqrt(x)} etc.
   223   \item \typ{sum(x, axis=0), product(x, axis=0), dot(a, bp)}   \inctime{10}
   223   \item \typ{sum(x, axis=0), product(x, axis=0), dot(a, bp)}   \inctime{10}
   224   \end{itemize}
   224   \end{itemize}
   225 
   225   \inctime{10}
   226 \end{frame}
   226 \end{frame}
   227 
   227 
   228 \subsection{Array Creation \& Slicing, Striding Arrays}
   228 \subsection{Array Creation \& Slicing, Striding Arrays}
   229 \begin{frame}[fragile]
   229 \begin{frame}[fragile]
   230   \frametitle{Array creation functions}
   230   \frametitle{Array creation functions}
   329 \end{itemize}
   329 \end{itemize}
   330 \end{frame}
   330 \end{frame}
   331        
   331        
   332 \subsection{Plots - Lines, Labels and Legends}
   332 \subsection{Plots - Lines, Labels and Legends}
   333 \begin{frame}[fragile]
   333 \begin{frame}[fragile]
   334   \frametitle{Basic plotting \ldots}
   334   \frametitle{Basic plotting}
   335 \begin{lstlisting}
   335 \begin{lstlisting}
   336 # Set properties of objects:
   336 # Set properties of objects:
   337 >>> l, = plot(x, sin(x))
   337 >>> l, = plot(x, sin(x))
   338 # Why "l,"?
   338 # Why "l,"?
   339 >>> setp(l, linewidth=2.0, color='r')
   339 >>> setp(l, linewidth=2.0, color='r')
   344 >>> close() # Close figure.
   344 >>> close() # Close figure.
   345 \end{lstlisting}
   345 \end{lstlisting}
   346 \end{frame}
   346 \end{frame}
   347 
   347 
   348 \begin{frame}[fragile]
   348 \begin{frame}[fragile]
   349     \frametitle{Multiple figures}
   349    \frametitle{Working with text \ldots}
   350 
   350 %\begin{itemize}
   351 \begin{lstlisting}
   351 %  \item We already saw LaTeX markup support!
   352 >>> figure(1)
   352 %\end{itemize}
   353 >>> plot(x, sin(x))
   353 \begin{lstlisting}
   354 >>> figure(2)
   354 >>> w = arange(-2,2,.1)
   355 >>> plot(x, tanh(x))
   355 >>> plot(w,exp(-(w*w))*cos)
   356 >>> figure(1)
   356 >>> ylabel('$f(\omega)$')
   357 >>> title('Easy as 1,2,3')
   357 >>> xlabel('$\omega$')
       
   358 >>> title(r"$f(\omega)=e^{-\omega^2}
       
   359             cos({\omega^2})$")
       
   360 >>> annotate('maxima',xy=(0, 1), 
       
   361              xytext=(1, 0.8), 
       
   362              arrowprops=dict(
       
   363              facecolor='black', 
       
   364              shrink=0.05))
   358 \end{lstlisting}
   365 \end{lstlisting}
   359     
   366     
   360 \end{frame}
   367 \end{frame}
   361 
   368 
   362 \begin{frame}[fragile]
   369 \begin{frame}[fragile]
   363   \frametitle{Legends and Annotation}
   370   \frametitle{Legends}
   364 \begin{lstlisting}
   371 \begin{lstlisting}
   365 >>> plot(x, cos(5*x), 'r--', 
   372 >>> plot(x, cos(5*x), 'r--', 
   366          label='cosine')
   373          label='cosine')
   367 >>> plot(x, sin(5*x), 'g--', 
   374 >>> plot(x, sin(5*x), 'g--', 
   368          label='sine')
   375          label='sine')
   373 >>> text(1,0, '(1,0)')
   380 >>> text(1,0, '(1,0)')
   374 \end{lstlisting}
   381 \end{lstlisting}
   375 \end{frame}
   382 \end{frame}
   376 
   383 
   377 \begin{frame}[fragile]
   384 \begin{frame}[fragile]
   378     \frametitle{More commands \ldots}
   385     \frametitle{Multiple figures}
   379     \begin{lstlisting}
   386 
   380 # semilog, loglog 
   387 \begin{lstlisting}
   381 >>> x = 10.**(-arange(100)*0.1)
   388 >>> figure(1)
   382 >>> semilogx(x, x)
   389 >>> plot(x, sin(x))
   383 >>> semilogy(x, x)
   390 >>> figure(2)
   384 >>> loglog(x, x)
   391 >>> plot(x, tanh(x))
   385 >>> loglog(x, x*x)
   392 >>> figure(1)
   386     \end{lstlisting}
   393 >>> title('Easy as 1,2,3')
   387 \end{frame}
   394 \end{lstlisting}
   388 
   395     
   389 \begin{frame}[fragile]
   396 
   390     \frametitle{More plots \ldots}
       
   391     \begin{lstlisting}
       
   392 >>> clf()
       
   393 >>> t = arange(0.1, 4, 0.1)
       
   394 >>> s = exp(-t)
       
   395 >>> e = 0.1*abs(randn(len(s)))
       
   396 >>> errorbar(t, s, e)
       
   397 # Scatter plots
       
   398 >>> clf()
       
   399 >>> t = randn(len(e))
       
   400 >>> scatter(t, e, c=s)
       
   401     \end{lstlisting}
       
   402 \end{frame}
   397 \end{frame}
   403 
   398 
   404 \begin{frame}[fragile]
   399 \begin{frame}[fragile]
   405     \frametitle{Note: \typ{pylab} in Python scripts}
   400     \frametitle{Note: \typ{pylab} in Python scripts}
   406 \begin{lstlisting}
   401 \begin{lstlisting}
   701   \end{block}
   696   \end{block}
   702 \end{columns}
   697 \end{columns}
   703 \end{frame}
   698 \end{frame}
   704 
   699 
   705 \begin{frame}[fragile] \frametitle{Maps}
   700 \begin{frame}[fragile] \frametitle{Maps}
   706   \includegraphics[height=2.5in, interpolate=true]{data/plotmap}  
   701   \includegraphics[height=2.3in, interpolate=true]{data/plotmap}  
   707   \begin{center}
   702   \begin{center}
   708     \tiny
   703     \tiny
   709     For details see \url{http://matplotlib.sourceforge.net/screenshots/plotmap.py}
   704     For details see \url{http://matplotlib.sourceforge.net/screenshots/plotmap.py}
   710   \end{center}
   705   \end{center}
   711 \end{frame}
   706 \end{frame}