day1/session1.tex
changeset 171 29c0c504750c
parent 147 6874a667dc4e
child 180 e442b9e23972
equal deleted inserted replaced
170:36ed5cdf5fde 171:29c0c504750c
   213 
   213 
   214 \begin{frame}[fragile]
   214 \begin{frame}[fragile]
   215 \frametitle{Another example}
   215 \frametitle{Another example}
   216   \begin{lstlisting}
   216   \begin{lstlisting}
   217 In []: clf()
   217 In []: clf()
       
   218 #Clears the plot area.
   218 In []: y = linspace(0, 2*pi, 51)
   219 In []: y = linspace(0, 2*pi, 51)
   219 In []: plot(y, sin(2*y))
   220 In []: plot(y, sin(2*y))
   220 In []: xlabel('y')
   221 In []: xlabel('y')
   221 In []: ylabel('sin(2y)')
   222 In []: ylabel('sin(2y)')
   222   \end{lstlisting}
   223   \end{lstlisting}
       
   224 \emphbar{By default plots would be overlayed!}
   223 \end{frame}
   225 \end{frame}
   224 
   226 
   225 \begin{frame}[fragile]
   227 \begin{frame}[fragile]
   226 \frametitle{Title and Legends}
   228 \frametitle{Title and Legends}
   227 \vspace*{-0.15in}
   229 \vspace*{-0.15in}
   229 %  \small
   231 %  \small
   230 \begin{lstlisting}
   232 \begin{lstlisting}
   231 In []: title('Sinusoids')
   233 In []: title('Sinusoids')
   232 #Sets the title of the figure
   234 #Sets the title of the figure
   233 In []: legend(['sin(2y)'])
   235 In []: legend(['sin(2y)'])
   234 # When no label, or to change
       
   235 \end{lstlisting}
   236 \end{lstlisting}
   236 %  \small
   237 %  \small
   237 %  \end{block}
   238 %  \end{block}
   238   \vspace*{-0.1in}
   239   \vspace*{-0.1in}
   239   \begin{center}
   240   \begin{center}
   241   \end{center}
   242   \end{center}
   242 \end{frame}
   243 \end{frame}
   243 
   244 
   244 \begin{frame}[fragile]
   245 \begin{frame}[fragile]
   245 \frametitle{Changing Legend Placement}
   246 \frametitle{Changing Legend Placement}
   246 \vspace*{-0.1in}
       
   247 \begin{lstlisting}
       
   248 In []: legend(['sin(2y)'], loc=(.8,.1)) 
       
   249 #(x,y) is position of lower-left 
       
   250 #corner of legend box.
       
   251 \end{lstlisting}
       
   252 %\vspace*{-0.2in}
       
   253 \begin{center}
       
   254   \includegraphics[height=2in, interpolate=true]{data/loc}  
       
   255 \end{center}
       
   256 \end{frame}
       
   257 
       
   258 \begin{frame}[fragile]
       
   259 \frametitle{Changing Legend Placement}
       
   260 \begin{columns}
   247 \begin{columns}
   261     \column{0.6\textwidth}
   248     \column{0.6\textwidth}
   262 \begin{block}{}
   249 \begin{block}{}
   263     \small
   250     \small
   264 \begin{lstlisting}
   251 \begin{lstlisting}
   265 In []: legend(['sin(2y)'], 
   252 In []: legend(['sin(2y)'], 
   266          loc='right')
   253          loc='center')
   267 \end{lstlisting}
   254 \end{lstlisting}
   268     \small
   255     \small
   269 \end{block}
   256 \end{block}
       
   257  \includegraphics[height=2in, interpolate=true]{data/position}  
   270 \column{0.45\textwidth}
   258 \column{0.45\textwidth}
   271 \vspace{-0.2in}
   259 \vspace{-0.2in}
   272 \begin{lstlisting}
   260 \begin{lstlisting}
   273 Location String   
   261 Location String   
   274 ===============   
   262 ===============   
   285 'center'          
   273 'center'          
   286 \end{lstlisting}
   274 \end{lstlisting}
   287 \end{columns}
   275 \end{columns}
   288 \end{frame}
   276 \end{frame}
   289 
   277 
       
   278 \begin{frame}[fragile]
       
   279 \frametitle{For placing legend at $(x,y)$}
       
   280 \vspace*{-0.1in}
       
   281 \begin{lstlisting}
       
   282 In []: legend(['sin(2y)'], loc=(.8,.1)) 
       
   283 #(x,y) is position of lower-left 
       
   284 #corner of legend box.
       
   285 \end{lstlisting}
       
   286 %\vspace*{-0.2in}
       
   287 \begin{center}
       
   288   \includegraphics[height=2in, interpolate=true]{data/loc}  
       
   289 \end{center}
       
   290 \end{frame}
   290 
   291 
   291 \begin{frame}[fragile]
   292 \begin{frame}[fragile]
   292 \frametitle{Saving \& Closing}
   293 \frametitle{Saving \& Closing}
   293 \begin{lstlisting}
   294 \begin{lstlisting}
   294 In []: savefig('sin.png')
   295 In []: savefig('sin.png')
   296 In []: close()
   297 In []: close()
   297 \end{lstlisting}
   298 \end{lstlisting}
   298 \end{frame}
   299 \end{frame}
   299 
   300 
   300 \begin{frame}[fragile]
   301 \begin{frame}[fragile]
   301 \frametitle{Multiple Figures}
   302 \frametitle{Plotting seprate figures}
   302 \begin{lstlisting}
   303 \begin{lstlisting}
   303 In []: figure(1)
   304 In []: figure(1)
   304 In []: plot(y, sin(y))
   305 In []: plot(y, sin(y))
   305 In []: figure(2)
   306 In []: figure(2)
   306 In []: plot(y, cos(y))
   307 In []: plot(y, cos(y))
   357 \end{frame}
   358 \end{frame}
   358 
   359 
   359 \begin{frame}[fragile]
   360 \begin{frame}[fragile]
   360 \frametitle{Review Problem}
   361 \frametitle{Review Problem}
   361 \begin{enumerate}
   362 \begin{enumerate}
   362 \item Plot x, -x, sin(x), xsin(x) in the range $-5\pi$ to $5\pi$
   363 \item Plot x, -x, sin(x), xsin(x) in range $-5\pi$ to $5\pi$
   363 \item Add a legend
   364 \item Add a legend
   364 \item Annotate the origin
   365 \item Annotate the origin
   365 \item Set axis limits to the range of x
   366 \item Set axis limits to the range of x
   366 \end{enumerate}
   367 \end{enumerate}
   367 \begin{lstlisting}
   368 \begin{lstlisting}
   390 In []: xlim(5*pi, 5*pi)
   391 In []: xlim(5*pi, 5*pi)
   391 In []: ylim(5*pi, 5*pi)
   392 In []: ylim(5*pi, 5*pi)
   392 \end{lstlisting}
   393 \end{lstlisting}
   393 }
   394 }
   394 \end{frame}
   395 \end{frame}
   395 
   396 \begin{frame}
       
   397   \frametitle{Things we have learned}
       
   398   \begin{itemize}
       
   399   \item Creating plots.
       
   400   \item Handling labels and legends.
       
   401   \item Changing properties of plot.
       
   402   \end{itemize}
       
   403 \end{frame}
   396 \begin{frame}[fragile]
   404 \begin{frame}[fragile]
   397   \begin{center}
   405   \begin{center}
   398   End of Session-1\\
   406   End of Session-1\\
   399   \alert{Don't Close \typ{IPython}}
   407   \alert{Don't Close \typ{IPython}}
   400   \end{center}
   408   \end{center}