summaryrefslogtreecommitdiff
path: root/day1/cheatsheet1.tex
diff options
context:
space:
mode:
authorShantanu Choudhary2009-11-19 22:26:00 +0530
committerShantanu Choudhary2009-11-19 22:26:00 +0530
commita2d2a9b7b95067bb458628db820e2e993babcc50 (patch)
tree1ff9f336777ca1f6ffdc21f75ef546b9be64b77b /day1/cheatsheet1.tex
parentc2b86508b7a9c0ad75e3d9feb795cc735585866c (diff)
downloadworkshops-a2d2a9b7b95067bb458628db820e2e993babcc50.tar.gz
workshops-a2d2a9b7b95067bb458628db820e2e993babcc50.tar.bz2
workshops-a2d2a9b7b95067bb458628db820e2e993babcc50.zip
Modified cheat sheet of session 1 and session 6 day 1.
Diffstat (limited to 'day1/cheatsheet1.tex')
-rwxr-xr-xday1/cheatsheet1.tex74
1 files changed, 50 insertions, 24 deletions
diff --git a/day1/cheatsheet1.tex b/day1/cheatsheet1.tex
index 4439a49..11fd385 100755
--- a/day1/cheatsheet1.tex
+++ b/day1/cheatsheet1.tex
@@ -37,19 +37,52 @@ Do you really want to exit ([y]/n)? y
\end{lstlisting} %$
\section{Plotting}
+\subsection{linspace}
+\typ{In []: x = linspace(start, stop, num)}\\
+\typ{linspace} returns array of length \typ{num}, for which \typ{x[0] = start} and \typ{x[num-1] = stop} \\
+\emph{Please note indices of array starts from zero(0)}
-\subsection{Label}
+\subsection{plot}
+\typ{In []: plot(X, Y)}\\
+For given arrays of equal length(above case X and Y), \typ{plot} plots the correspoding *x* and *y* pairs taken from X and Y.
+
+\subsection{Colors of plots}
+\typ{In []: plot(y, sin(y), 'g')}\\
+Plots graph with green color. Other options available are:
+\begin{lstlisting}
+ 'r' ---> Red
+ 'b' ---> Blue
+ 'r' ---> Red
+ 'c' ---> Cyan
+ 'm' ---> Magenta
+ 'y' ---> Yellow
+ 'k' ---> Black
+ 'w' ---> White
+\end{lstlisting}
+One can also set the line width of plot using optional argument \typ{linewidth}. For example:\\
+\typ{In []: plot(x, cos(x), 'r', linewidth=2)}\\
+Plots the line with linewidth = 2
+\subsection{label and title}
+\typ{In []: xlabel('Length') #sets *x* axis label to Length}\\
+\typ{In []: ylabel('Time') #sets *y* axis label to Time.}\\
+\typ{In []: title('Sinusoids') #sets title of plot}\\
+\\
+\textbf{Additionally}\\
Pylab accepts TeX equation expressions in any text expression. To get something like:\\
$\sigma_i=15$ \\
on title of figure use:
\begin{lstlisting}
- title('$\sigma_i=15$')
+In []: title('$\sigma_i=15$')
\end{lstlisting}
Same way one can have TeX expression on xlabel, ylabel etc.
\subsection{legends}
+\typ{In []: legend('sin(x)',loc=center)} \\
+Placec a legend on the current plot at location *loc*.\\
Apart from \kwrd{center}, some other \kwrd{loc} which can be specified are:
\begin{lstlisting}
+'best'
+'right'
'upper right'
'upper left'
'lower left'
@@ -64,26 +97,20 @@ One can also mention explicit co-ordinates for placement of legend.
\begin{lstlisting}
In []: legend(['sin(2y)'], loc=(.8,.1))
\end{lstlisting}
-\typ{loc = 0, 1} (left top position of graph)\\
+\typ{loc = 0, 1} (top left position of graph)\\
\typ{loc = 0.5, 0.5} (center of graph).
-\subsection{Saving figures}
-One can save figure in any of these formats: png, pdf, ps, eps and svg.
+\subsection{Annotate}
+\typ{In []: annotate('local max', xy=(1.5, 1))}\\
+Annotates current plot with text, 'local max', at position specified to \typ{xy}.
-\subsection{Colors of plots}
-\typ{In []: plot(y, sin(y), 'g')}\\
-Plots graph with green color. Other options available are:
-\begin{lstlisting}
- 'r' ---> Red
- 'b' ---> Blue
- 'r' ---> Red
- 'c' ---> Cyan
- 'm' ---> Magenta
- 'y' ---> Yellow
- 'k' ---> Black
- 'w' ---> White
-\end{lstlisting}
+\subsection{Saving figures}
+\typ{In []: savefig('sinusoids.png')}\\
+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.
+\subsection{Miscellaneous}
+\typ{In []: clf() #Clears the current plot area}\\
+\typ{In []: close() #Closes the figure}
\section{Saving and running scripts}
\begin{itemize}
\item \typ{\%hist}\\
@@ -105,14 +132,13 @@ In []: xlabel('x')
In []: title('Sinusoidal Waves')
In []: legend(['sin(x)', 'cos(x)'])
In []: annotate('origin', xy=(0, 0))
-In []: xmin, xman = xlim() # Without arguments gets
-In []: ymin, ymax = ylim() # values
-
-In []: xlim(0, 2 * pi) # With values, sets the
-In []: ylim(ymin - 0.2, ymax + 0.2) # specified values
+In []: xmin, xman = xlim() # returns current X axis limits.
+In []: ymin, ymax = ylim()
+In []: xlim(0, 2 * pi) # sets the X axis limits to passed values
+In []: ylim(ymin - 0.2, ymax + 0.2)
In []: savefig('sin.png') # Save figure
-In []: close() # Closes the figure
+In []: close()
\end{lstlisting}
\section{References}