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] |