summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--other-type-of-plots/bar-chart-hatch.pngbin0 -> 26170 bytes
-rw-r--r--other-type-of-plots/company-a-data.txt2
-rw-r--r--other-type-of-plots/script.rst22
-rw-r--r--savefig/script.rst35
-rw-r--r--savefig/slides.org99
-rw-r--r--savefig/slides.tex185
6 files changed, 324 insertions, 19 deletions
diff --git a/other-type-of-plots/bar-chart-hatch.png b/other-type-of-plots/bar-chart-hatch.png
new file mode 100644
index 0000000..7b48125
--- /dev/null
+++ b/other-type-of-plots/bar-chart-hatch.png
Binary files differ
diff --git a/other-type-of-plots/company-a-data.txt b/other-type-of-plots/company-a-data.txt
new file mode 100644
index 0000000..06f4ca4
--- /dev/null
+++ b/other-type-of-plots/company-a-data.txt
@@ -0,0 +1,2 @@
+2.000000000000000000e+03 2.001000000000000000e+03 2.002000000000000000e+03 2.003000000000000000e+03 2.004000000000000000e+03 2.005000000000000000e+03 2.006000000000000000e+03 2.007000000000000000e+03 2.008000000000000000e+03 2.009000000000000000e+03 2.010000000000000000e+03
+2.300000000000000000e+01 5.500000000000000000e+01 3.200000000000000000e+01 6.500000000000000000e+01 8.800000000000000000e+01 5.000000000000000000e+00 1.400000000000000000e+01 6.700000000000000000e+01 2.300000000000000000e+01 2.300000000000000000e+01 1.200000000000000000e+01
diff --git a/other-type-of-plots/script.rst b/other-type-of-plots/script.rst
index 010045b..aa5e25b 100644
--- a/other-type-of-plots/script.rst
+++ b/other-type-of-plots/script.rst
@@ -20,7 +20,6 @@ In this tutorial we will cover scatter plot, pie chart, bar chart and
log plot. We will also see few other plots and also introduce you to
the matplotlib help.
-
Let us start with scatter plot.
{{{ switch to the next slide }}}
@@ -55,11 +54,12 @@ profit percentages.
{{{ close the file and switch to the terminal }}}
-To product the scatter plot first we need to load the data from the
+To produce the scatter plot first we need to load the data from the
file using ``loadtxt``. We learned in one of the previous sessions,
and it can be done as ::
- year,profit = loadtxt('/home/fossee/other-plot/company-a-data.txt',dtype=type(int()))
+ year,profit =
+ loadtxt('/home/fossee/other-plot/company-a-data.txt',dtype=type(int()))
Now in-order to generate the scatter graph we will use the function
``scatter()``
@@ -100,9 +100,9 @@ We can plot the pie chart using the function ``pie()``.
pie(profit,labels=year)
-Notice that we passed two arguments to the function ``pie()``. The
-first one the values and the next one the set of labels to be used in
-the pie chart.
+Notice that we passed two arguments to the function ``pie()``. First
+one the values and the next one the set of labels to be used in the
+pie chart.
{{{ switch to the next slide which has the problem statement of
problem to be tried out }}}
@@ -195,14 +195,10 @@ matplotlib over the internet.
Help about matplotlib can be obtained from
matplotlib.sourceforge.net/contents.html
-.. #[[Anoop: I am not so sure how to do the rest of it, so I guess we
- can just browse through the side and tell them few. What is your
- opinion??]]
-
-Now let us see few plots from
-matplotlib.sourceforge.net/users/screenshots.html
-{{{ browse through the site quickly }}}
+More plots can be seen at
+matplotlib.sourceforge.net/users/screenshots.html and also at
+matplotlib.sourceforge.net/gallery.html
{{{ switch to recap slide }}}
diff --git a/savefig/script.rst b/savefig/script.rst
index 506428e..87080d0 100644
--- a/savefig/script.rst
+++ b/savefig/script.rst
@@ -9,8 +9,16 @@
Savefig
=======
-Hello and welcome to the tutorial. In this tutorial you will learn how
-to save plots using Python.
+{{{ Show the first slide }}}
+
+Hello and welcome to the tutorial saving plots.
+
+{{{ switch to next slide, outline slide }}}
+
+In this tutorial you will learn how to save plots using Python. And
+saving in different formats, and locating the file in the file system.
+
+{{{ switch to next slide, a sine wave}}}
Start your IPython interpreter with the command ::
@@ -38,9 +46,11 @@ Done! we have made a very basic sine plot, now let us see how to save
the plot for future use so that you can embed the plot in your
reports.
+{{{ switch to next slide, savefig() }}}
+
{{{ Switch the focus to IPython interpreter window }}}
-For saving the plot, we will use savefig function, and it has to be
+For saving the plot, we will use ``savefig()`` function, and it has to be
done with the plot window open. The statement is, ::
savefig('/home/fossee/sine.png')
@@ -73,6 +83,8 @@ Yes, the file ``sine.png`` is here and let us check it.
close it and return to IPython interpreter, make sure the plot window
is still open, also don't close the file browser window }}}
+{{{ switch to next slide, More on savefig() }}}
+
So in-order to save a plot, we use ``savefig`` function. ``savefig``
can save the plot in many formats, such as pdf - portable document
format, ps - post script, eps - encapsulated post script, svg -
@@ -81,15 +93,19 @@ support transparency etc.
.. #[[slide must give the extensions for the files - Anoop]]
+{{{ switch to next slide, exercise 1 }}}
+
Let us now try to save the plot in eps format. ``eps`` stands for
encapsulated post script, and it can be embedded in your latex
-documents.
+documents. Pause here and try to figure it out yourself.
{{{ Switch focus to the already open plot window }}}
We still have the sine plot with us, and now let us save the plot as
``sine.eps``.
+{{{ switch to next slide, solution 1 }}}
+
{{{ Switch focus to IPython interpreter }}}
Now, We will save the plot using the function ``savefig`` ::
@@ -105,10 +121,17 @@ seconds and then double click and open the file }}}
Yes! the new file ``sine.eps`` is here.
+{{{ switch to next slide, exercise 2 }}}
+
Now you may try saving the same in pdf, ps, svg formats.
-Let us review what we have learned in this session! We have learned to
-save plots in different formats using the function ``savefig()``.
+{{{ Switch to summary slide }}}
+
+This brings us to the end of this tutorial, in this tutorial we
+learned to save plots using the function ``savefig()``. Saving the
+plots in different formats and locating the files in the file system.
+
+{{{ switch to Thank you slide }}}
Thank you!
diff --git a/savefig/slides.org b/savefig/slides.org
new file mode 100644
index 0000000..4278516
--- /dev/null
+++ b/savefig/slides.org
@@ -0,0 +1,99 @@
+#+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: Savefig
+#+AUTHOR: FOSSEE
+#+EMAIL: info@fossee.in
+#+DATE: 2010-10-11 Mon
+
+#+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
+ - Saving plots.
+ - Plotting in different formats.
+ - Locating the file in the file system.
+
+* Creating a basic plot
+ Plot a sine wave from -3pi to 3pi.
+ #+begin_src python
+ In []: x = linspace(-3*pi,3*pi,100)
+
+ In []: plot(x, sin(x))
+ #+end_src
+* savefig()
+** savefig() - to save plots
+ : syntax: savefig(fname)
+** example
+*** savefig('/home/fossee/sine.png')
+ - file sine.png saved to the folder /home/fossee
+ - .png - file type
+
+* More on savefig()
+** Recall
+ - .png - file type
+** File types supported
+*** .pdf - PDF(Portable Document Format)
+*** .ps - PS(Post Script)
+*** .eps - Encapsulated Post Script
+ ~to be used with~ LaTeX ~documents~
+*** .svg - Scalable Vector Graphics
+ ~vector graphics~
+*** .png - Portable Network Graphics
+ ~supports transparency~
+* Exercise 1
+ Save the sine plot in the format EPS which can be embedded in LaTeX documents.
+* Solution 1
+ #+begin_src python
+ savefig('/home/fossee/sine.eps')
+ #+end_src
+* Exercise 2
+ Save the sine plot in PDF, PS and SVG formats.
+
+* Summary
+ You should now be able to
+ - Use ~savefig()~ function
+ - Save plots in different formats
+ - PDF
+ - PS
+ - PNG
+ - SVG
+ - EPS
+ - Locating the files in file system.
+
+* 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
+
+
diff --git a/savefig/slides.tex b/savefig/slides.tex
new file mode 100644
index 0000000..06d530b
--- /dev/null
+++ b/savefig/slides.tex
@@ -0,0 +1,185 @@
+% Created 2010-10-11 Mon 17:08
+\documentclass[presentation]{beamer}
+\usepackage[latin1]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{t1enc}
+\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}}
+
+\title{Savefig}
+\author{FOSSEE}
+\date{2010-10-11 Mon}
+
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+\begin{document}
+
+\maketitle
+
+
+
+
+
+
+
+
+
+\begin{frame}
+\frametitle{Outline}
+\label{sec-1}
+
+\begin{itemize}
+\item Saving plots.
+\item Plotting in different formats.
+\item Locating the file in the file system.
+\end{itemize}
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Creating a basic plot}
+\label{sec-2}
+
+ Plot a sine wave from -3pi to 3pi.
+\begin{verbatim}
+In []: x = linspace(-3*pi,3*pi,100)
+
+In []: plot(x, sin(x))
+\end{verbatim}
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{savefig()}
+\label{sec-3}
+\begin{itemize}
+
+\item savefig() - to save plots
+\label{sec-3_1}%
+\begin{verbatim}
+ syntax: savefig(fname)
+\end{verbatim}
+
+
+\item example
+\label{sec-3_2}%
+\begin{itemize}
+
+\item savefig('/home/fossee/sine.png')
+\label{sec-3_2_1}%
+\begin{itemize}
+\item file sine.png saved to the folder /home/fossee
+\item .png - file type
+\end{itemize}
+
+
+\end{itemize} % ends low level
+\end{itemize} % ends low level
+\end{frame}
+\begin{frame}
+\frametitle{More on savefig()}
+\label{sec-4}
+\begin{itemize}
+
+\item Recall
+\label{sec-4_1}%
+\begin{itemize}
+\item .png - file type
+\end{itemize}
+
+
+\item File types supported
+\label{sec-4_2}%
+\begin{itemize}
+
+\item .pdf - PDF(Portable Document Format)\\
+\label{sec-4_2_1}%
+\item .ps - PS(Post Script)\\
+\label{sec-4_2_2}%
+\item .eps - Encapsulated Post Script\\
+\label{sec-4_2_3}%
+\texttt{to be used with} \LaTeX{} \texttt{documents}
+
+\item .svg - Scalable Vector Graphics\\
+\label{sec-4_2_4}%
+\texttt{vector graphics}
+
+\item .png - Portable Network Graphics\\
+\label{sec-4_2_5}%
+\texttt{supports transparency}
+\end{itemize} % ends low level
+\end{itemize} % ends low level
+\end{frame}
+\begin{frame}
+\frametitle{Exercise 1}
+\label{sec-5}
+
+ Save the sine plot in the format EPS which can be embedded in \LaTeX{} documents.
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 1}
+\label{sec-6}
+
+\begin{verbatim}
+savefig('/home/fossee/sine.eps')
+\end{verbatim}
+\end{frame}
+\begin{frame}
+\frametitle{Exercise 2}
+\label{sec-7}
+
+ Save the sine plot in PDF, PS and SVG formats.
+\end{frame}
+\begin{frame}
+\frametitle{Summary}
+\label{sec-8}
+
+ You should now be able to
+\begin{itemize}
+\item Use \texttt{savefig()} function
+\item Save plots in different formats
+
+\begin{itemize}
+\item PDF
+\item PS
+\item PNG
+\item SVG
+\item EPS
+\end{itemize}
+
+\item Locating the files in file system.
+\end{itemize}
+
+
+\end{frame}
+\begin{frame}
+\frametitle{Thank you!}
+\label{sec-9}
+
+ \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{frame}
+
+\end{document}