author | Shantanu <shantanu@fossee.in> |
Wed, 18 Nov 2009 17:08:39 +0530 | |
changeset 308 | d93be08d69f8 |
parent 307 | be62ebb11407 |
child 317 | 0eca6c542fce |
permissions | -rwxr-xr-x |
107
647239f95c4a
Added rough draft of slides and cheatsheet for Interactive Plotting.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
1 |
\documentclass[12pt]{article} |
295
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
2 |
|
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
3 |
|
107
647239f95c4a
Added rough draft of slides and cheatsheet for Interactive Plotting.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
4 |
\title{Interactive Plotting} |
647239f95c4a
Added rough draft of slides and cheatsheet for Interactive Plotting.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
5 |
\author{FOSSEE} |
295
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
6 |
\usepackage{listings} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
7 |
\lstset{language=Python, |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
8 |
basicstyle=\ttfamily, |
308
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
9 |
commentstyle=\itshape\bfseries, |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
10 |
showstringspaces=false, |
295
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
11 |
} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
12 |
\newcommand{\typ}[1]{\lstinline{#1}} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
13 |
\usepackage[english]{babel} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
14 |
\usepackage[latin1]{inputenc} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
15 |
\usepackage{times} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
16 |
\usepackage[T1]{fontenc} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
17 |
\usepackage{ae,aecompl} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
18 |
\usepackage{mathpazo,courier,euler} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
19 |
\usepackage[scaled=.95]{helvet} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
20 |
|
107
647239f95c4a
Added rough draft of slides and cheatsheet for Interactive Plotting.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
21 |
\begin{document} |
264
c3a1de5b8216
Updated day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
107
diff
changeset
|
22 |
\date{} |
c3a1de5b8216
Updated day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
107
diff
changeset
|
23 |
\vspace{-1in} |
c3a1de5b8216
Updated day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
107
diff
changeset
|
24 |
\begin{center} |
c3a1de5b8216
Updated day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
107
diff
changeset
|
25 |
\LARGE{Interactive Plotting}\\ |
c3a1de5b8216
Updated day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
107
diff
changeset
|
26 |
\large{FOSSEE} |
c3a1de5b8216
Updated day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
107
diff
changeset
|
27 |
\end{center} |
c3a1de5b8216
Updated day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
107
diff
changeset
|
28 |
\section{Starting up...} |
107
647239f95c4a
Added rough draft of slides and cheatsheet for Interactive Plotting.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
29 |
|
295
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
30 |
\begin{lstlisting} |
107
647239f95c4a
Added rough draft of slides and cheatsheet for Interactive Plotting.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
31 |
$ ipython -pylab |
295
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
32 |
\end{lstlisting} |
264
c3a1de5b8216
Updated day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
107
diff
changeset
|
33 |
Exiting |
295
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
34 |
\begin{lstlisting} |
264
c3a1de5b8216
Updated day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
107
diff
changeset
|
35 |
In [2]: (Ctrl-D)^D |
c3a1de5b8216
Updated day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
107
diff
changeset
|
36 |
Do you really want to exit ([y]/n)? y |
307
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
37 |
\end{lstlisting} %$ |
107
647239f95c4a
Added rough draft of slides and cheatsheet for Interactive Plotting.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
38 |
|
264
c3a1de5b8216
Updated day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
107
diff
changeset
|
39 |
\section{Plotting} |
295
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
40 |
|
307
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
41 |
\subsection{Label} |
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
42 |
Pylab accepts TeX equation expressions in any text expression. To get something like:\\ |
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
43 |
$\sigma_i=15$ \\ |
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
44 |
on title of figure use: |
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
45 |
\begin{lstlisting} |
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
46 |
title('$\sigma_i=15$') |
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
47 |
\end{lstlisting} |
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
48 |
Same way one can have TeX expression on xlabel, ylabel etc. |
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
49 |
|
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
50 |
\subsection{legends} |
308
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
51 |
Apart from \kwrd{center}, some other \kwrd{loc} which can be specified are: |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
52 |
\begin{lstlisting} |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
53 |
'upper right' |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
54 |
'upper left' |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
55 |
'lower left' |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
56 |
'lower right' |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
57 |
'center left' |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
58 |
'center right' |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
59 |
'lower center' |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
60 |
'upper center' |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
61 |
\end{lstlisting} |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
62 |
\newpage |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
63 |
One can also mention explicit co-ordinates for placement of legend. |
307
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
64 |
\begin{lstlisting} |
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
65 |
In []: legend(['sin(2y)'], loc=(.8,.1)) |
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
66 |
\end{lstlisting} |
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
67 |
\typ{loc = 0, 1} (left top position of graph)\\ |
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
68 |
\typ{loc = 0.5, 0.5} (center of graph). |
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
69 |
|
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
70 |
\subsection{Saving figures} |
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
71 |
One can save figure in any of these formats: png, pdf, ps, eps and svg. |
295
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
72 |
|
308
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
73 |
\subsection{Colors of plots} |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
74 |
\typ{In []: plot(y, sin(y), 'g')}\\ |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
75 |
Plots graph with green color. Other options available are: |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
76 |
\begin{lstlisting} |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
77 |
'r' ---> Red |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
78 |
'b' ---> Blue |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
79 |
'r' ---> Red |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
80 |
'c' ---> Cyan |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
81 |
'm' ---> Magenta |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
82 |
'y' ---> Yellow |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
83 |
'k' ---> Black |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
84 |
'w' ---> White |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
85 |
\end{lstlisting} |
295
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
86 |
|
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
87 |
\section{Saving and running scripts} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
88 |
\begin{itemize} |
308
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
89 |
\item \typ{\%hist}\\ |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
90 |
It returns the logs of all commands(including mistakes) used in IPython interpreter. |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
91 |
\item \typ{\%hist -n}\\ |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
92 |
It disables the line number representation of logs. |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
93 |
\item \typ{\%save four\_plot.py 16 18-27}\\ |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
94 |
For creating a script named four\_plot which includes line 16 and line 18 to 27 of logs. |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
95 |
\item \typ{\%run -i four\_plot.py}\\ |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
96 |
Running the python script inside IPython interpreter. |
295
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
97 |
\end{itemize} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
98 |
|
308
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
99 |
\section{Example} |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
100 |
\begin{lstlisting} |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
101 |
In []: x = linspace(0, 2*pi, 50) |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
102 |
In []: plot(x, sin(x), 'g') |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
103 |
In []: plot(x, cos(x), 'r', linewidth=2) |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
104 |
In []: xlabel('x') |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
105 |
In []: title('Sinusoidal Waves') |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
106 |
In []: legend(['sin(x)', 'cos(x)']) |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
107 |
In []: annotate('origin', xy=(0, 0)) |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
108 |
In []: xmin, xman = xlim() # Without arguments gets |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
109 |
In []: ymin, ymax = ylim() # values |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
110 |
|
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
111 |
In []: xlim(0, 2 * pi) # With values, sets the |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
112 |
In []: ylim(ymin - 0.2, ymax + 0.2) # specified values |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
113 |
|
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
114 |
In []: savefig('sin.png') # Save figure |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
115 |
In []: close() # Closes the figure |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
116 |
\end{lstlisting} |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
117 |
|
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
118 |
\section{References} |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
119 |
\begin{itemize} |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
120 |
\item For documentation on IPython refer: \\ \url{http://ipython.scipy.org/moin/Documentation} |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
121 |
\item Plotting(matplotlib) related documentation are available at:\\ \url{http://matplotlib.sourceforge.net/contents.html} |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
122 |
\item Explore examples and plots based on matplotlib at \\ \url{http://matplotlib.sourceforge.net/examples/index.html} |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
123 |
\end{itemize} |
107
647239f95c4a
Added rough draft of slides and cheatsheet for Interactive Plotting.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
124 |
\end{document} |
647239f95c4a
Added rough draft of slides and cheatsheet for Interactive Plotting.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
125 |