day2/session1.tex
changeset 7 adcc40e2bf70
parent 6 1f9492506ba2
child 8 41bdf277c755
equal deleted inserted replaced
6:1f9492506ba2 7:adcc40e2bf70
   325 >>> savefig('/tmp/test.eps')
   325 >>> savefig('/tmp/test.eps')
   326 \end{lstlisting}
   326 \end{lstlisting}
   327 \begin{itemize}
   327 \begin{itemize}
   328   \item Also: PNG, PDF, PS, EPS, SVG, PDF
   328   \item Also: PNG, PDF, PS, EPS, SVG, PDF
   329 \end{itemize}
   329 \end{itemize}
       
   330 \inctime{5}
   330 \end{frame}
   331 \end{frame}
   331        
   332        
   332 \subsection{Plots - Lines, Labels and Legends}
   333 \subsection{Plots - Lines, Labels}
   333 \begin{frame}[fragile]
   334 \begin{frame}[fragile]
   334   \frametitle{Basic plotting \ldots}
   335   \frametitle{Basic plotting}
   335 \begin{lstlisting}
   336 \begin{lstlisting}
   336 # Set properties of objects:
   337 # Set properties of objects:
   337 >>> l, = plot(x, sin(x))
   338 >>> l, = plot(x, sin(x))
   338 # Why "l,"?
   339 # Why "l,"?
   339 >>> setp(l, linewidth=2.0, color='r')
   340 >>> setp(l, linewidth=2.0, color='r')
   344 >>> close() # Close figure.
   345 >>> close() # Close figure.
   345 \end{lstlisting}
   346 \end{lstlisting}
   346 \end{frame}
   347 \end{frame}
   347 
   348 
   348 \begin{frame}[fragile]
   349 \begin{frame}[fragile]
       
   350   \frametitle{Working with text \ldots}
       
   351 %\begin{itemize}
       
   352 %  \item We already saw LaTeX markup support!
       
   353 %\end{itemize}
       
   354 \begin{lstlisting}
       
   355 >>> w = arange(-2,2,.1)
       
   356 >>> plot(w,exp(-(w*w))*cos)
       
   357 >>> ylabel('$f(\omega)$')
       
   358 >>> xlabel('$\omega$')
       
   359 >>> title(r"$f(\omega)=e^{-\omega^2}
       
   360             cos({\omega^2})$")
       
   361 >>> annotate('maxima',xy=(0, 1), 
       
   362              xytext=(1, 0.8), 
       
   363              arrowprops=dict(
       
   364              facecolor='black', 
       
   365              shrink=0.05))
       
   366 \end{lstlisting}
       
   367 \end{frame}
       
   368 
       
   369 \begin{frame}[fragile]
   349     \frametitle{Multiple figures}
   370     \frametitle{Multiple figures}
   350 
   371 
   351 \begin{lstlisting}
   372 \begin{lstlisting}
   352 >>> figure(1)
   373 >>> figure(1)
   353 >>> plot(x, sin(x))
   374 >>> plot(x, sin(x))
   358 \end{lstlisting}
   379 \end{lstlisting}
   359     
   380     
   360 \end{frame}
   381 \end{frame}
   361 
   382 
   362 \begin{frame}[fragile]
   383 \begin{frame}[fragile]
   363   \frametitle{Legends and Annotation}
       
   364 \begin{lstlisting}
       
   365 >>> plot(x, cos(5*x), 'r--', 
       
   366          label='cosine')
       
   367 >>> plot(x, sin(5*x), 'g--', 
       
   368          label='sine')
       
   369 >>> legend() 
       
   370 # Or use:
       
   371 >>> legend(['cosine', 'sine'])
       
   372 # Annotation:
       
   373 >>> text(1,0, '(1,0)')
       
   374 \end{lstlisting}
       
   375 \end{frame}
       
   376 
       
   377 \begin{frame}[fragile]
       
   378     \frametitle{More commands \ldots}
       
   379     \begin{lstlisting}
       
   380 # semilog, loglog 
       
   381 >>> x = 10.**(-arange(100)*0.1)
       
   382 >>> semilogx(x, x)
       
   383 >>> semilogy(x, x)
       
   384 >>> loglog(x, x)
       
   385 >>> loglog(x, x*x)
       
   386     \end{lstlisting}
       
   387 \end{frame}
       
   388 
       
   389 \begin{frame}[fragile]
       
   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}
       
   403 
       
   404 \begin{frame}[fragile]
       
   405     \frametitle{Note: \typ{pylab} in Python scripts}
   384     \frametitle{Note: \typ{pylab} in Python scripts}
   406 \begin{lstlisting}
   385 \begin{lstlisting}
   407 import pylab
   386 import pylab
   408 x = pylab.linspace(0, 20, 1000)
   387 x = pylab.linspace(0, 20, 1000)
   409 pylab.plot(x, pylab.sin(x))
   388 pylab.plot(x, pylab.sin(x))
   410 
   389 
   411 # Can also use:
   390 # Can also use:
   412 from pylab import linspace, sin, plot
   391 from pylab import linspace, sin, plot
   413 \end{lstlisting}
   392 \end{lstlisting}
       
   393 \inctime{5}
   414 \end{frame}
   394 \end{frame}
   415 
   395 
   416 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   396 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   417 \subsection{Types of Plots}
   397 \subsection{Types of Plots}
   418 \begin{frame}[fragile]
   398 \begin{frame}[fragile]
   706   \includegraphics[height=2.5in, interpolate=true]{data/plotmap}  
   686   \includegraphics[height=2.5in, interpolate=true]{data/plotmap}  
   707   \begin{center}
   687   \begin{center}
   708     \tiny
   688     \tiny
   709     For details see \url{http://matplotlib.sourceforge.net/screenshots/plotmap.py}
   689     For details see \url{http://matplotlib.sourceforge.net/screenshots/plotmap.py}
   710   \end{center}
   690   \end{center}
       
   691 \inctime{5}
   711 \end{frame}
   692 \end{frame}
   712 
   693 
   713 
   694 
   714 \begin{frame}
   695 \begin{frame}
   715   \frametitle{More information}
   696   \frametitle{More information}
   717   \item More information here: \url{http://matplotlib.sf.net}
   698   \item More information here: \url{http://matplotlib.sf.net}
   718   \item \url{http://matplotlib.sf.net/tutorial.html}
   699   \item \url{http://matplotlib.sf.net/tutorial.html}
   719   \item \url{http://matplotlib.sf.net/screenshots.html}
   700   \item \url{http://matplotlib.sf.net/screenshots.html}
   720   \end{itemize}
   701   \end{itemize}
   721 
   702 
   722   \inctime{25}
       
   723 \end{frame}
   703 \end{frame}
   724 
   704 
   725 \begin{frame}
   705 \begin{frame}
   726   \frametitle{Problem set 1.0}
   706   \frametitle{Problem set 1.0}
   727   \begin{enumerate}
   707   \begin{enumerate}
   764                   done.
   744                   done.
   765           \end{enumerate}
   745           \end{enumerate}
   766       \item Show rate of convergence for a first and second order finite
   746       \item Show rate of convergence for a first and second order finite
   767           difference of sin(x)
   747           difference of sin(x)
   768 \end{enumerate}
   748 \end{enumerate}
   769 \inctime{30}
   749 \inctime{20}
   770 \end{frame}
   750 \end{frame}
   771 \end{document}
   751 \end{document}