1 \documentclass[12pt]{article} |
1 \documentclass[12pt]{article} |
|
2 |
|
3 |
2 \title{Interactive Plotting} |
4 \title{Interactive Plotting} |
3 \author{FOSSEE} |
5 \author{FOSSEE} |
|
6 \usepackage{listings} |
|
7 \lstset{language=Python, |
|
8 basicstyle=\ttfamily, |
|
9 commentstyle=\itshape\bfseries |
|
10 } |
|
11 \newcommand{\typ}[1]{\lstinline{#1}} |
|
12 \usepackage[english]{babel} |
|
13 \usepackage[latin1]{inputenc} |
|
14 \usepackage{times} |
|
15 \usepackage[T1]{fontenc} |
|
16 \usepackage{ae,aecompl} |
|
17 \usepackage{mathpazo,courier,euler} |
|
18 \usepackage[scaled=.95]{helvet} |
|
19 |
4 \begin{document} |
20 \begin{document} |
5 \date{} |
21 \date{} |
6 \vspace{-1in} |
22 \vspace{-1in} |
7 \begin{center} |
23 \begin{center} |
8 \LARGE{Interactive Plotting}\\ |
24 \LARGE{Interactive Plotting}\\ |
9 \large{FOSSEE} |
25 \large{FOSSEE} |
10 \end{center} |
26 \end{center} |
11 \section{Starting up...} |
27 \section{Starting up...} |
12 |
28 |
13 \begin{verbatim} |
29 \begin{lstlisting} |
14 $ ipython -pylab |
30 $ ipython -pylab |
15 \end{verbatim} |
31 \end{lstlisting} |
16 Exiting |
32 Exiting |
17 \begin{verbatim} |
33 \begin{lstlisting} |
18 In [2]: (Ctrl-D)^D |
34 In [2]: (Ctrl-D)^D |
19 Do you really want to exit ([y]/n)? y |
35 Do you really want to exit ([y]/n)? y |
20 \end{verbatim} |
36 \end{lstlisting} |
21 Breaking out of loops |
|
22 \begin{verbatim} |
|
23 In [1]: while True: |
|
24 ...: print "Hello, World!" |
|
25 ...: |
|
26 Hello, World! |
|
27 Hello, World!(Ctrl-C)^C |
|
28 \end{verbatim} |
|
29 |
37 |
30 \section{Plotting} |
38 \section{Plotting} |
31 \begin{verbatim} |
39 |
|
40 \begin{lstlisting} |
32 In [1]: x = linspace(0, 2*pi, 50) |
41 In [1]: x = linspace(0, 2*pi, 50) |
33 In [2]: plot(x,sin(x)) |
42 In [2]: plot(x, sin(x)) |
34 In [3]: xlabel('x') |
43 In [3]: xlabel('x') |
35 In [4]: ylabel('sin(x)') |
44 In [4]: ylabel('sin(x)') |
36 In [5]: legend(['x', '-x', 'sin(x)', 'xsin(x)']) |
45 In [5]: title('Sinusoids') |
37 In [6]: annotate('origin', xy=(0, 0), xytext=(0, -7), |
46 In [6]: legend(['sin(y)']) |
38 arrowprops=dict(shrink=0.05)) |
47 In [7]: legend(['sin(2y)'], loc = 'center') |
39 In [7]: xlim(5*pi, 5*pi) |
48 # loc = 'upper right', 'upper left', 'lower left, 'lower right', 'center left', |
40 In [8]: ylim(5*pi, 5*pi) |
49 # 'center right', 'lower center', 'upper center', 'best', 'right', 'center' |
41 In [9]: clf() #Clears the Plot area |
50 |
42 \end{verbatim} |
51 In [8]: legend(['sin(2y)'], loc = (.8, .1)) |
|
52 |
|
53 In [9]: savefig('sin.png') # Save figure |
|
54 In [10]: close() # Closes the figure |
|
55 |
|
56 In [11]: clf() # Clears the Plot area |
|
57 |
|
58 In [12]: plot(y, sin(y), 'g') |
|
59 # Colors can be: 'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w' |
|
60 |
|
61 In [13]: plot(y, cos(y), 'r', linewidth=2) |
|
62 |
|
63 In [14]: legend(['x', '-x']) |
|
64 In [15]: annotate('origin', xy=(0, 0)) |
|
65 |
|
66 In [16]: xmin, xman = xlim() # Without arguments gets |
|
67 In [17]: ymin, ymax = ylim() # values |
|
68 |
|
69 In [18]: xlim(0, 2 * pi) # With values, sets the |
|
70 In [19]: ylim(ymin - 0.2, ymax + 0.2) # specified values |
|
71 \end{lstlisting} |
|
72 |
|
73 \section{Saving and running scripts} |
|
74 \begin{itemize} |
|
75 \item \typ{\%hist} |
|
76 \item \typ{\%save four\_plot.py 16 18-27} |
|
77 \item \typ{\%run -i four\_plot.py} |
|
78 \end{itemize} |
|
79 |
43 \end{document} |
80 \end{document} |
44 |
81 |