author | Prabhu Ramachandran <prabhu@aero.iitb.ac.in> |
Mon, 28 Jun 2010 00:14:02 -0500 | |
branch | scipy2010 |
changeset 426 | 7d8738ce004d |
parent 341 | 7ae88b9da553 |
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} |
317
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
40 |
\subsection{linspace} |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
41 |
\typ{In []: x = linspace(start, stop, num)}\\ |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
42 |
\typ{linspace} returns array of length \typ{num}, for which \typ{x[0] = start} and \typ{x[num-1] = stop} \\ |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
43 |
\emph{Please note indices of array starts from zero(0)} |
295
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
44 |
|
317
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
45 |
\subsection{plot} |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
46 |
\typ{In []: plot(X, Y)}\\ |
330
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
328
diff
changeset
|
47 |
For given arrays of equal length(above case X and Y), \typ{plot} plots the corresponding *x* and *y* pairs taken from X and Y. |
317
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
48 |
|
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
49 |
\subsection{Colors of plots} |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
50 |
\typ{In []: plot(y, sin(y), 'g')}\\ |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
51 |
Plots graph with green color. Other options available are: |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
52 |
\begin{lstlisting} |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
53 |
'r' ---> Red |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
54 |
'b' ---> Blue |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
55 |
'r' ---> Red |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
56 |
'c' ---> Cyan |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
57 |
'm' ---> Magenta |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
58 |
'y' ---> Yellow |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
59 |
'k' ---> Black |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
60 |
'w' ---> White |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
61 |
\end{lstlisting} |
325 | 62 |
One can set the width of the plotline using optional argument \typ{linewidth}. For example:\\ |
317
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
63 |
\typ{In []: plot(x, cos(x), 'r', linewidth=2)}\\ |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
64 |
Plots the line with linewidth = 2 |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
65 |
\subsection{label and title} |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
66 |
\typ{In []: xlabel('Length') #sets *x* axis label to Length}\\ |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
67 |
\typ{In []: ylabel('Time') #sets *y* axis label to Time.}\\ |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
68 |
\typ{In []: title('Sinusoids') #sets title of plot}\\ |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
69 |
\\ |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
70 |
\textbf{Additionally}\\ |
307
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
71 |
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
|
72 |
$\sigma_i=15$ \\ |
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
73 |
on title of figure use: |
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
74 |
\begin{lstlisting} |
317
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
75 |
In []: title('$\sigma_i=15$') |
307
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
76 |
\end{lstlisting} |
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
77 |
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
|
78 |
|
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
79 |
\subsection{legends} |
317
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
80 |
\typ{In []: legend('sin(x)',loc=center)} \\ |
340
347ff2714deb
Minor edits to correct spellings.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
328
diff
changeset
|
81 |
Places a legend on the current plot at location *loc*.\\ |
328
4075482a9770
Minor edits to remove errors.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
325
diff
changeset
|
82 |
Apart from \typ{center}, some other \typ{loc} which can be specified are: |
308
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
83 |
\begin{lstlisting} |
317
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
84 |
'best' |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
85 |
'right' |
308
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
86 |
'upper right' |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
87 |
'upper left' |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
88 |
'lower left' |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
89 |
'lower right' |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
90 |
'center left' |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
91 |
'center right' |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
92 |
'lower center' |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
93 |
'upper center' |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
94 |
\end{lstlisting} |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
95 |
\newpage |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
96 |
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
|
97 |
\begin{lstlisting} |
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
98 |
In []: legend(['sin(2y)'], loc=(.8,.1)) |
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
99 |
\end{lstlisting} |
317
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
100 |
\typ{loc = 0, 1} (top left position of graph)\\ |
307
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
101 |
\typ{loc = 0.5, 0.5} (center of graph). |
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
102 |
|
317
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
103 |
\subsection{Annotate} |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
104 |
\typ{In []: annotate('local max', xy=(1.5, 1))}\\ |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
105 |
Annotates current plot with text, 'local max', at position specified to \typ{xy}. |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
106 |
|
307
be62ebb11407
Added changes for cheat sheet 1.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
107 |
\subsection{Saving figures} |
317
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
108 |
\typ{In []: savefig('sinusoids.png')}\\ |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
109 |
Saves the current figure with file name 'sinusoids.png' in current working directory. 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
|
110 |
|
317
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
111 |
\subsection{Miscellaneous} |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
112 |
\typ{In []: clf() #Clears the current plot area}\\ |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
113 |
\typ{In []: close() #Closes the figure} |
295
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
114 |
\section{Saving and running scripts} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
115 |
\begin{itemize} |
308
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
116 |
\item \typ{\%hist}\\ |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
117 |
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
|
118 |
\item \typ{\%hist -n}\\ |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
119 |
It disables the line number representation of logs. |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
120 |
\item \typ{\%save four\_plot.py 16 18-27}\\ |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
121 |
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
|
122 |
\item \typ{\%run -i four\_plot.py}\\ |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
123 |
Running the python script inside IPython interpreter. |
295
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
124 |
\end{itemize} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
264
diff
changeset
|
125 |
|
308
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
126 |
\section{Example} |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
127 |
\begin{lstlisting} |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
128 |
In []: x = linspace(0, 2*pi, 50) |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
129 |
In []: plot(x, sin(x), 'g') |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
130 |
In []: plot(x, cos(x), 'r', linewidth=2) |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
131 |
In []: xlabel('x') |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
132 |
In []: title('Sinusoidal Waves') |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
133 |
In []: legend(['sin(x)', 'cos(x)']) |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
134 |
In []: annotate('origin', xy=(0, 0)) |
317
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
135 |
In []: xmin, xman = xlim() # returns current X axis limits. |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
136 |
In []: ymin, ymax = ylim() |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
137 |
In []: xlim(0, 2 * pi) # sets the X axis limits to passed values |
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
138 |
In []: ylim(ymin - 0.2, ymax + 0.2) |
308
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
139 |
|
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
140 |
In []: savefig('sin.png') # Save figure |
317
0eca6c542fce
Modified cheat sheet of session 1 and session 6 day 1.
Shantanu <shantanu@fossee.in>
parents:
308
diff
changeset
|
141 |
In []: close() |
308
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
142 |
\end{lstlisting} |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
143 |
|
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
144 |
\section{References} |
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
145 |
\begin{itemize} |
328
4075482a9770
Minor edits to remove errors.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
325
diff
changeset
|
146 |
\item For documentation on IPython refer: \\ http://ipython.scipy.org/moin/Documentation |
4075482a9770
Minor edits to remove errors.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
325
diff
changeset
|
147 |
\item Plotting(matplotlib) related documentation are available at:\\ http://matplotlib.sourceforge.net/contents.html |
4075482a9770
Minor edits to remove errors.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
325
diff
changeset
|
148 |
\item Explore examples and plots based on matplotlib at \\ http://matplotlib.sourceforge.net/examples/index.html |
308
d93be08d69f8
cheat sheet 1 Interactive Plotting.
Shantanu <shantanu@fossee.in>
parents:
307
diff
changeset
|
149 |
\end{itemize} |
107
647239f95c4a
Added rough draft of slides and cheatsheet for Interactive Plotting.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
150 |
\end{document} |
647239f95c4a
Added rough draft of slides and cheatsheet for Interactive Plotting.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
151 |