Slides for embellishing a plot LO.
authorPuneeth Chaganti <punchagan@fossee.in>
Mon, 11 Oct 2010 00:57:50 +0530
changeset 273 1639ef25a231
parent 272 08638b1e211e
child 274 1f8921b59ff0
Slides for embellishing a plot LO.
embellishing_a_plot/script.rst
embellishing_a_plot/slides.org
embellishing_a_plot/slides.tex
--- a/embellishing_a_plot/script.rst	Mon Oct 11 00:57:10 2010 +0530
+++ b/embellishing_a_plot/script.rst	Mon Oct 11 00:57:50 2010 +0530
@@ -6,6 +6,15 @@
    C - 
    D - 
 
+.. By the end of this tutorial you will be able to 
+
+..  * Modify the attributes of the plot -- color, line style, linewidth
+..  * Add a title to the plot with embedded LaTeX.
+..  * Label x and y axes. 
+..  * Add annotations to the plot. 
+..  * Set and Get the limits of axes. 
+
+
 .. Prerequisites
 .. -------------
 
@@ -174,6 +183,10 @@
 
 .. #[Madhu: I did not understand the question]
 
+::
+    clf()
+    plot(x, cos(x), 'r--')
+
 Now that we know how to produce a bare minimum plot with colour, style
 and thickness of our interest, we shall look at decorating the plot.
 
@@ -184,8 +197,8 @@
 
 {{{ Show the plot window and switch back to terminal }}}
 
-We now have the plot in a colour and linewidth of our interest. As you can see,
-the figure does not have any description describing the plot.
+We now have the plot in a colour and linewidth of our interest. As you
+can see, the figure does not have any description describing the plot.
 
 .. #[Madhu: Added "not". See the diff]
 
@@ -204,10 +217,10 @@
 
 The formatting in title is messed and it does not look clean. You can imagine
 what would be the situation if there were fractions and more complex functions
-like log and exp. Wouldn't it be good if there was LaTex like formatting?
+like log and exp. Wouldn't it be good if there was LaTeX like formatting?
 
 That is also possible by adding a $ sign before and after the part of the 
-string that should be in LaTex style.
+string that should be in LaTeX style.
 
 for instance, we can use
 ::
@@ -217,9 +230,9 @@
 and we get the polynomial formatted properly.
 
 .. #[Nishanth]: Unsure if I have to give this exercise since enclosing the whole
-             string in LaTex style is not good
+             string in LaTeX style is not good
 
-.. #[[Anoop: I guess you can go ahead with the LaTex thing, it's
+.. #[[Anoop: I guess you can go ahead with the LaTeX thing, it's
      cool!]]
 .. #[Madhu: Instead of saying LaTeX style you can say Typeset math
      since that is how it is called as. I am not sure as well. It
@@ -228,7 +241,7 @@
 {{{ Pause here and try out the following exercises }}}
 
 %% 4 %% Change the title of the figure such that the whole title is formatted
-        in LaTex style
+        in LaTeX style
 
 {{{ continue from the paused state }}}
 
@@ -262,11 +275,11 @@
 
 {{{ Pause here and try out the following exercises }}}
 
-%% 5 %% Set the x and y labels as "x" and "f(x)" in LaTex style.
+%% 5 %% Set the x and y labels as "x" and "f(x)" in LaTeX style.
 
 {{{ continue from paused state }}}
 
-Since we need LaTex style formatting, all we have to do is enclose the string
+Since we need LaTeX style formatting, all we have to do is enclose the string
 in between two $. Hence,
 ::
 
@@ -303,6 +316,10 @@
 
 {{{ continue from paused state }}}
 
+::
+
+  annotate("root", xy=(-4,0))  
+
 As we can see, every annotate command makes a new annotation on the figure.
 
 Now we have everything we need to decorate a plot. but the plot would be
@@ -354,7 +371,7 @@
 
  * Modifying the attributes of plot by passing additional arguments
  * How to add title
- * How to incorporate LaTex style formatting
+ * How to incorporate LaTeX style formatting
  * How to label x and y axes
  * How to add annotations
  * How to set the limits of axes
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/embellishing_a_plot/slides.org	Mon Oct 11 00:57:50 2010 +0530
@@ -0,0 +1,111 @@
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+#+BEAMER_FRAME_LEVEL: 1
+
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
+#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER:\usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER:  commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER:  showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+
+#+TITLE:    Embellishing a Plot
+#+AUTHOR:    FOSSEE
+#+EMAIL:     
+#+DATE:    
+
+#+DESCRIPTION: 
+#+KEYWORDS: 
+#+LANGUAGE:  en
+#+OPTIONS:   H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS:   TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
+
+* Outline
+  + Modifying the color, line style & linewidth of a plot
+  + Adding a title to the plot (with embedded LaTeX)
+  + Labelling the axes
+  + Annotating the plot
+  + Setting the limits of axes. 
+* Question 1
+  Plot sin(x) in blue colour and with linewidth as 3
+* Solution 1
+  #+begin_src python
+    In []: clf()
+    In []: plot(x, sin(x), 'b', linewidth=3)
+  #+end_src
+* Question 2
+  Plot the sine curve with green filled circles.
+* Solution 2
+  #+begin_src python
+    In []: clf()
+    In []: plot(x, cos(x), 'go')
+  #+end_src
+* Question 3
+  Plot the curve of x vs tan(x) in red dashed line and linewidth 3
+* Solution 3
+  #+begin_src python
+    In []: clf()
+    In []: plot(x, cos(x), 'r--')
+  #+end_src
+* Question 4
+  Change the title of the figure such that the whole title is
+  formatted in LaTex style
+* Solution 4 
+  #+begin_src python
+    In []: title("$Parabolic function -x^2+4x-5$")
+  #+end_src
+* Question 5
+  Set the x and y labels as "x" and "f(x)" in LaTex style.
+* Solution 5
+  #+begin_src python
+    In []: xlabel("$x$")
+    In []: yalbel("$f(x)$")
+  #+end_src
+* Question 6
+  Make an annotation called "root" at the point (-4, 0). What happens
+  to the first annotation?
+* Solution 6
+  #+begin_src python
+    In []: annotate("root", xy=(-4,0))  
+  #+end_src
+* Question 7
+  Set the limits of axes such that the area of interest is the
+  rectangle (-1, -15) and (3, 0)
+* Solution 7
+  #+begin_src python
+    In []: xlim(-1, 3)
+    In []: ylim(-15, 0)
+  #+end_src
+* Summary
+  + Modifying the attributes of plot by passing additional arguments
+  + How to add title
+  + How to incorporate LaTeX style formatting
+  + How to label x and y axes
+  + How to add annotations
+  + How to set the limits of axes
+
+* Thank you!
+#+begin_latex
+  \begin{block}{}
+  \begin{center}
+  This spoken tutorial has been produced by the
+  \textcolor{blue}{FOSSEE} team, which is funded by the 
+  \end{center}
+  \begin{center}
+    \textcolor{blue}{National Mission on Education through \\
+      Information \& Communication Technology \\ 
+      MHRD, Govt. of India}.
+  \end{center}  
+  \end{block}
+#+end_latex
+
+
--- a/embellishing_a_plot/slides.tex	Mon Oct 11 00:57:10 2010 +0530
+++ b/embellishing_a_plot/slides.tex	Mon Oct 11 00:57:50 2010 +0530
@@ -1,95 +1,187 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%Tutorial slides on Python.
-%
-% Author: FOSSEE 
-% Copyright (c) 2009, FOSSEE, IIT Bombay
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-\documentclass[14pt,compress]{beamer}
-%\documentclass[draft]{beamer}
-%\documentclass[compress,handout]{beamer}
-%\usepackage{pgfpages} 
-%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
-
-% Modified from: generic-ornate-15min-45min.de.tex
-\mode<presentation>
-{
-  \usetheme{Warsaw}
-  \useoutertheme{infolines}
-  \setbeamercovered{transparent}
-}
-
-\usepackage[english]{babel}
+% Created 2010-10-10 Sun 17:32
+\documentclass[presentation]{beamer}
 \usepackage[latin1]{inputenc}
-%\usepackage{times}
 \usepackage[T1]{fontenc}
-
-\usepackage{ae,aecompl}
-\usepackage{mathpazo,courier,euler}
-\usepackage[scaled=.95]{helvet}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
 
-\definecolor{darkgreen}{rgb}{0,0.5,0}
-
-\usepackage{listings}
-\lstset{language=Python,
-    basicstyle=\ttfamily\bfseries,
-    commentstyle=\color{red}\itshape,
-  stringstyle=\color{darkgreen},
-  showstringspaces=false,
-  keywordstyle=\color{blue}\bfseries}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Macros
-\setbeamercolor{emphbar}{bg=blue!20, fg=black}
-\newcommand{\emphbar}[1]
-{\begin{beamercolorbox}[rounded=true]{emphbar} 
-      {#1}
- \end{beamercolorbox}
-}
-\newcounter{time}
-\setcounter{time}{0}
-\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
-
-\newcommand{\typ}[1]{\lstinline{#1}}
-
-\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}}  }
-
-% Title page
-\title{Your Title Here}
-
-\author[FOSSEE] {FOSSEE}
-
-\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\title{Embellishing a Plot}
+\author{FOSSEE}
 \date{}
 
-% DOCUMENT STARTS
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
 \begin{document}
 
+\maketitle
+
+
+
+
+
+
+
+
+
 \begin{frame}
-  \maketitle
+\frametitle{Outline}
+\label{sec-1}
+
+\begin{itemize}
+\item Modifying the color, line style \& linewidth of a plot
+\item Adding a title to the plot (with embedded \LaTeX{})
+\item Labelling the axes
+\item Annotating the plot
+\item Setting the limits of axes.
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Question 1}
+\label{sec-2}
+
+  Plot sin(x) in blue colour and with linewidth as 3
 \end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 1}
+\label{sec-3}
 
+\lstset{language=Python}
+\begin{lstlisting}
+In []: clf()
+In []: plot(x, sin(x), 'b', linewidth=3)
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 2}
+\label{sec-4}
+
+  Plot the sine curve with green filled circles.
+\end{frame}
 \begin{frame}[fragile]
-  \frametitle{Outline}
-  \begin{itemize}
-    \item 
-  \end{itemize}
+\frametitle{Solution 2}
+\label{sec-5}
+
+\lstset{language=Python}
+\begin{lstlisting}
+In []: clf()
+In []: plot(x, cos(x), 'go')
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 3}
+\label{sec-6}
+
+  Plot the curve of x vs tan(x) in red dashed line and linewidth 3
 \end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 3}
+\label{sec-7}
+
+\lstset{language=Python}
+\begin{lstlisting}
+In []: clf()
+In []: plot(x, cos(x), 'r--')
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 4}
+\label{sec-8}
+
+  Change the title of the figure such that the whole title is
+  formatted in LaTex style
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 4}
+\label{sec-9}
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%              All other slides here.                  %%
-%% The same slides will be used in a classroom setting. %% 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\lstset{language=Python}
+\begin{lstlisting}
+In []: title("$Parabolic function -x^2+4x-5$")
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 5}
+\label{sec-10}
 
+  Set the x and y labels as ``x'' and ``f(x)'' in LaTex style.
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 5}
+\label{sec-11}
+
+\lstset{language=Python}
+\begin{lstlisting}
+In []: xlabel("$x$")
+In []: yalbel("$f(x)$")
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 6}
+\label{sec-12}
+
+  Make an annotation called ``root'' at the point (-4, 0). What happens
+  to the first annotation?
+\end{frame}
 \begin{frame}[fragile]
-  \frametitle{Summary}
-  \begin{itemize}
-    \item 
-  \end{itemize}
+\frametitle{Solution 6}
+\label{sec-13}
+
+\lstset{language=Python}
+\begin{lstlisting}
+In []: annotate("root", xy=(-4,0))
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 7}
+\label{sec-14}
+
+  Set the limits of axes such that the area of interest is the
+  rectangle (-1, -15) and (3, 0)
 \end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 7}
+\label{sec-15}
 
+\lstset{language=Python}
+\begin{lstlisting}
+In []: xlim(-1, 3)
+In []: ylim(-15, 0)
+\end{lstlisting}
+\end{frame}
 \begin{frame}
-  \frametitle{Thank you!}  
+\frametitle{Summary}
+\label{sec-16}
+
+\begin{itemize}
+\item Modifying the attributes of plot by passing additional arguments
+\item How to add title
+\item How to incorporate \LaTeX{} style formatting
+\item How to label x and y axes
+\item How to add annotations
+\item How to set the limits of axes
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Thank you!}
+\label{sec-17}
+
   \begin{block}{}
   \begin{center}
   This spoken tutorial has been produced by the