# HG changeset patch # User Shantanu # Date 1256555894 -19800 # Node ID 29c0c504750cde5696a15edc115d0e26af7beef1 # Parent 36ed5cdf5fde32fccaa4154ccf8ec7fa39a97490 Added some changes suggested during the review. diff -r 36ed5cdf5fde -r 29c0c504750c day1/data/position.png Binary file day1/data/position.png has changed diff -r 36ed5cdf5fde -r 29c0c504750c day1/session1.tex --- a/day1/session1.tex Mon Oct 26 14:23:49 2009 +0530 +++ b/day1/session1.tex Mon Oct 26 16:48:14 2009 +0530 @@ -215,11 +215,13 @@ \frametitle{Another example} \begin{lstlisting} In []: clf() +#Clears the plot area. In []: y = linspace(0, 2*pi, 51) In []: plot(y, sin(2*y)) In []: xlabel('y') In []: ylabel('sin(2y)') \end{lstlisting} +\emphbar{By default plots would be overlayed!} \end{frame} \begin{frame}[fragile] @@ -231,7 +233,6 @@ In []: title('Sinusoids') #Sets the title of the figure In []: legend(['sin(2y)']) -# When no label, or to change \end{lstlisting} % \small % \end{block} @@ -243,30 +244,17 @@ \begin{frame}[fragile] \frametitle{Changing Legend Placement} -\vspace*{-0.1in} -\begin{lstlisting} -In []: legend(['sin(2y)'], loc=(.8,.1)) -#(x,y) is position of lower-left -#corner of legend box. -\end{lstlisting} -%\vspace*{-0.2in} -\begin{center} - \includegraphics[height=2in, interpolate=true]{data/loc} -\end{center} -\end{frame} - -\begin{frame}[fragile] -\frametitle{Changing Legend Placement} \begin{columns} \column{0.6\textwidth} \begin{block}{} \small \begin{lstlisting} In []: legend(['sin(2y)'], - loc='right') + loc='center') \end{lstlisting} \small \end{block} + \includegraphics[height=2in, interpolate=true]{data/position} \column{0.45\textwidth} \vspace{-0.2in} \begin{lstlisting} @@ -287,6 +275,19 @@ \end{columns} \end{frame} +\begin{frame}[fragile] +\frametitle{For placing legend at $(x,y)$} +\vspace*{-0.1in} +\begin{lstlisting} +In []: legend(['sin(2y)'], loc=(.8,.1)) +#(x,y) is position of lower-left +#corner of legend box. +\end{lstlisting} +%\vspace*{-0.2in} +\begin{center} + \includegraphics[height=2in, interpolate=true]{data/loc} +\end{center} +\end{frame} \begin{frame}[fragile] \frametitle{Saving \& Closing} @@ -298,7 +299,7 @@ \end{frame} \begin{frame}[fragile] -\frametitle{Multiple Figures} +\frametitle{Plotting seprate figures} \begin{lstlisting} In []: figure(1) In []: plot(y, sin(y)) @@ -359,7 +360,7 @@ \begin{frame}[fragile] \frametitle{Review Problem} \begin{enumerate} -\item Plot x, -x, sin(x), xsin(x) in the range $-5\pi$ to $5\pi$ +\item Plot x, -x, sin(x), xsin(x) in range $-5\pi$ to $5\pi$ \item Add a legend \item Annotate the origin \item Set axis limits to the range of x @@ -392,7 +393,14 @@ \end{lstlisting} } \end{frame} - +\begin{frame} + \frametitle{Things we have learned} + \begin{itemize} + \item Creating plots. + \item Handling labels and legends. + \item Changing properties of plot. + \end{itemize} +\end{frame} \begin{frame}[fragile] \begin{center} End of Session-1\\ diff -r 36ed5cdf5fde -r 29c0c504750c day2/3Dplotting.tex --- a/day2/3Dplotting.tex Mon Oct 26 14:23:49 2009 +0530 +++ b/day2/3Dplotting.tex Mon Oct 26 16:48:14 2009 +0530 @@ -156,6 +156,24 @@ \end{center} \end{frame} + +\begin{frame} + \frametitle{Is this new?} + \begin{center} + We have moved from: + \end{center} + \begin{columns} + \column{} + \hspace*{-1in} + \includegraphics[width=1.75in,height=1.75in, interpolate=true]{data/3832} + \column{}\hspace*{-0.25in} + To + \column{} + \hspace*{-1in} + \includegraphics[width=1.75in, height=1.75in, interpolate=true]{data/torus} + \end{columns} +\end{frame} + \begin{frame} \frametitle{3D visualization} \Large @@ -189,7 +207,212 @@ \inctime{10} \end{frame} -\section{Tools at your disposal} +\section{Tools available} + +\subsection{mlab} + +\begin{frame} + {Overview} + \Large + \begin{itemize} + \item Simple + \item Convenient + \item Full-featured + \end{itemize} +\end{frame} + +\begin{frame}[fragile] + + \frametitle{Getting started} + \myemph{\Large Vanilla:} + \begin{lstlisting}[language=bash] + $ ipython -wthread + \end{lstlisting} + \myemph{\Large with Pylab:} + \begin{lstlisting}[language=bash] + $ ipython -pylab -wthread + \end{lstlisting} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Using mlab} + + \begin{lstlisting} +>>> from enthought.mayavi import mlab + \end{lstlisting} + + \vspace*{0.5in} + + \myemph{\Large Try these} + + \vspace*{0.25in} + + \begin{lstlisting} +>>> mlab.test_ +>>> mlab.test_contour3d() +>>> mlab.test_contour3d?? + \end{lstlisting} +\end{frame} + +\begin{frame} + {Exploring the view} + \begin{columns} + \column{0.6\textwidth} + \pgfimage[width=3in]{MEDIA/m2/contour3d} + \column{0.4\textwidth} + \begin{itemize} + \item Mouse + \item Keyboard + \item Toolbar + \item Mayavi icon\pgfimage[width=0.2in]{MEDIA/m2/m2_icon} + \end{itemize} + \end{columns} +\end{frame} + +\begin{frame}[fragile] + \frametitle{plotting 3-D Surface: $x^2+y^2-z^2=1$} + \begin{lstlisting} +u,v = mgrid[-2:2:100j, -pi:pi:100j] +x=sqrt(u*u+1)*cos(v) +y=sqrt(u*u+1)*sin(v) +z=u +mlab.mesh(x,y,z) + \end{lstlisting} +\begin{figure} +\includegraphics[width=1in, height=1in, interpolate=true]{data/hyperboloid} +\end{figure} +\end{frame} + +\begin{frame}[fragile] + \frametitle{mgrid} + \begin{itemize} + \item Creates a multidimensional ``meshgrid'' + + \item In this particular case, creates 2 2D arrays: u,v. + \end{itemize} + \begin{lstlisting} +In []: mgrid[0:3,0:3] +Out[]: +array([[[0, 0, 0], + [1, 1, 1], + [2, 2, 2]], + + [[0, 1, 2], + [0, 1, 2], + [0, 1, 2]]]) + \end{lstlisting} +\end{frame} + +\begin{frame}[fragile] + \frametitle{mesh} + \begin{itemize} + \item Plots a surface from data supplied as 2D arrays. + \end{itemize} +\end{frame} + +\begin{frame}[fragile] + \frametitle{\mlab\ plotting functions} + \begin{columns} + \column{0.25\textwidth} + \myemph{Points in 3D space} + \column{0.5\textwidth} + \pgfimage[width=2in]{MEDIA/m2/mlab/points3d_ex} + \end{columns} + + \begin{lstlisting} +>>> from numpy import * +>>> t = linspace(0, 2*pi, 50) +>>> u = cos(t)*pi +>>> x, y, z = sin(u), cos(u), sin(t) + \end{lstlisting} + \emphbar{\PythonCode{>>> mlab.points3d(x, y, z)}} +\end{frame} + +\begin{frame} + \begin{columns} + \column{0.25\textwidth} + \myemph{Connected points in 3D space} + \column{0.5\textwidth} + \pgfimage[width=2.5in]{MEDIA/m2/mlab/plot3d_ex} + \end{columns} + \emphbar{\PythonCode{>>> mlab.plot3d(x, y, z, t)}} + + Plots lines between the points + +\end{frame} + +\begin{frame}[fragile] + \begin{columns} + \column{0.25\textwidth} + \myemph{\Large 2D data} + \column{0.5\textwidth} + \pgfimage[width=2in]{MEDIA/m2/mlab/surf_ex} + \end{columns} + \begin{lstlisting} +>>> x, y = mgrid[-3:3:100j,-3:3:100j] +>>> z = sin(x*x + y*y) + \end{lstlisting} + + \emphbar{\PythonCode{>>> mlab.surf(x, y, z)}} + + \alert{Assumes the points are rectilinear} + +\end{frame} + +\begin{frame}[fragile] + \myemph{\Large 2D data: \texttt{mlab.mesh}} + \vspace*{0.25in} + + \emphbar{\PythonCode{>>> mlab.mesh(x, y, z)}} + + \alert{Points needn't be regular} + + \vspace*{0.25in} +\begin{lstlisting} +>>> phi, theta = numpy.mgrid[0:pi:20j, +... 0:2*pi:20j] +>>> x = sin(phi)*cos(theta) +>>> y = sin(phi)*sin(theta) +>>> z = cos(phi) +>>> mlab.mesh(x, y, z, +... representation= +... 'wireframe') +\end{lstlisting} + +\end{frame} + +\begin{frame}[fragile] + + \begin{columns} + \column{0.25\textwidth} + \myemph{\Large 3D data} + \column{0.5\textwidth} + \pgfimage[width=1.5in]{MEDIA/m2/mlab/contour3d}\\ + \end{columns} +\begin{lstlisting} +>>> x, y, z = ogrid[-5:5:64j, +... -5:5:64j, +... -5:5:64j] +>>> mlab.contour3d(x*x*0.5 + y*y + + z*z*2) +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] + + \myemph{\Large 3D vector data: \PythonCode{mlab.quiver3d}} + \vspace*{0.25in} + + \pgfimage[width=2in]{MEDIA/m2/mlab/quiver3d_ex}\\ + +\begin{lstlisting} +>>> mlab.test_quiver3d() +\end{lstlisting} + +\emphbar{\PythonCode{obj = mlab.quiver3d(x, y, z, u, v, w)}} +\inctime{20} +\end{frame} + \subsection{Mayavi2} @@ -259,169 +482,6 @@ \end{frame} -\subsection{mlab} - -\begin{frame} - {Overview} - \Large - \begin{itemize} - \item Simple - \item Convenient - \item Full-featured - \end{itemize} -\end{frame} - -\begin{frame}[fragile] - - \frametitle{Getting started} - \myemph{\Large Vanilla:} - \begin{lstlisting}[language=bash] - $ ipython -wthread - \end{lstlisting} - \myemph{\Large with Pylab:} - \begin{lstlisting}[language=bash] - $ ipython -pylab -wthread - \end{lstlisting} -\end{frame} - -\begin{frame}[fragile] - \frametitle{Using mlab} - - \begin{lstlisting} ->>> from enthought.mayavi import mlab - \end{lstlisting} - - \vspace*{0.5in} - - \myemph{\Large Try these} - - \vspace*{0.25in} - - \begin{lstlisting} ->>> mlab.test_ ->>> mlab.test_contour3d() ->>> mlab.test_contour3d?? - \end{lstlisting} -\end{frame} - -\begin{frame} - {Exploring the view} - \begin{columns} - \column{0.6\textwidth} - \pgfimage[width=3in]{MEDIA/m2/contour3d} - \column{0.4\textwidth} - \begin{itemize} - \item Mouse - \item Keyboard - \item Toolbar - \item Mayavi icon\pgfimage[width=0.2in]{MEDIA/m2/m2_icon} - \end{itemize} - \end{columns} -\end{frame} - -\begin{frame}[fragile] - \frametitle{\mlab\ plotting functions} - \begin{columns} - \column{0.25\textwidth} - \myemph{\Large 0D data} - \column{0.5\textwidth} - \pgfimage[width=2in]{MEDIA/m2/mlab/points3d_ex} - \end{columns} - - \begin{lstlisting} ->>> from numpy import * ->>> t = linspace(0, 2*pi, 50) ->>> u = cos(t)*pi ->>> x, y, z = sin(u), cos(u), sin(t) - \end{lstlisting} - \emphbar{\PythonCode{>>> mlab.points3d(x, y, z)}} -\end{frame} - -\begin{frame} - \begin{columns} - \column{0.25\textwidth} - \myemph{\Large 1D data} - \column{0.5\textwidth} - \pgfimage[width=2.5in]{MEDIA/m2/mlab/plot3d_ex} - \end{columns} - \emphbar{\PythonCode{>>> mlab.plot3d(x, y, z, t)}} - - Plots lines between the points - -\end{frame} - -\begin{frame}[fragile] - \begin{columns} - \column{0.25\textwidth} - \myemph{\Large 2D data} - \column{0.5\textwidth} - \pgfimage[width=2in]{MEDIA/m2/mlab/surf_ex} - \end{columns} - \begin{lstlisting} ->>> x = mgrid[-3:3:100j,-3:3:100j] ->>> z = sin(x*x + y*y) - \end{lstlisting} - - \emphbar{\PythonCode{>>> mlab.surf(x, y, z)}} - - \alert{Assumes the points are rectilinear} - -\end{frame} - -\begin{frame}[fragile] - \myemph{\Large 2D data: \texttt{mlab.mesh}} - \vspace*{0.25in} - - \emphbar{\PythonCode{>>> mlab.mesh(x, y, z)}} - - \alert{Points needn't be regular} - - \vspace*{0.25in} -\begin{lstlisting} ->>> phi, theta = numpy.mgrid[0:pi:20j, -... 0:2*pi:20j] ->>> x = sin(phi)*cos(theta) ->>> y = sin(phi)*sin(theta) ->>> z = cos(phi) ->>> mlab.mesh(x, y, z, -... representation= -... 'wireframe') -\end{lstlisting} - -\end{frame} - -\begin{frame}[fragile] - - \begin{columns} - \column{0.25\textwidth} - \myemph{\Large 3D data} - \column{0.5\textwidth} - \pgfimage[width=1.5in]{MEDIA/m2/mlab/contour3d}\\ - \end{columns} -\begin{lstlisting} ->>> x, y, z = ogrid[-5:5:64j, -... -5:5:64j, -... -5:5:64j] ->>> mlab.contour3d(x*x*0.5 + y*y + - z*z*2) -\end{lstlisting} -\end{frame} - -\begin{frame}[fragile] - - \myemph{\Large 3D vector data: \PythonCode{mlab.quiver3d}} - \vspace*{0.25in} - - \pgfimage[width=2in]{MEDIA/m2/mlab/quiver3d_ex}\\ - -\begin{lstlisting} ->>> mlab.test_quiver3d() -\end{lstlisting} - -\emphbar{\PythonCode{obj = mlab.quiver3d(x, y, z, u, v, w)}} -\inctime{20} -\end{frame} - \begin{frame} {Getting hands dirty!} diff -r 36ed5cdf5fde -r 29c0c504750c day2/data/3832.jpg Binary file day2/data/3832.jpg has changed diff -r 36ed5cdf5fde -r 29c0c504750c day2/data/hyperboloid.png Binary file day2/data/hyperboloid.png has changed diff -r 36ed5cdf5fde -r 29c0c504750c day2/data/torus.png Binary file day2/data/torus.png has changed