1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
|
% Created 2011-05-23 Mon 15:48
\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\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}}
\title{}
\author{FOSSEE}
\date{}
\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
\begin{frame}
\begin{center}
\vspace{12pt}
\textcolor{blue}{\huge Other types of Plots}
\end{center}
\vspace{18pt}
\begin{center}
\vspace{10pt}
\includegraphics[scale=0.95]{../images/fossee-logo.png}\\
\vspace{5pt}
\scriptsize Developed by FOSSEE Team, IIT-Bombay. \\
\scriptsize Funded by National Mission on Education through ICT\\
\scriptsize MHRD,Govt. of India\\
\includegraphics[scale=0.30]{../images/iitb-logo.png}\\
\end{center}
\end{frame}
\begin{frame}
\frametitle{Objectives}
\label{sec-2}
At the end of this tutorial, you will be able to,
\begin{itemize}
\item Create scatter plot
\item Create pie charts
\item Create bar charts
\item Create log-log plots
\item Use the \verb~matplotlib~ help
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Pre-requisite}
\label{sec-3}
Spoken tuorial on -
\begin{itemize}
\item Loading Data from Files.
\item Plotting Data.
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Scatter plot}
\label{sec-4}
Scatter plot - a collection of points,where each point determines
it's position on the horizontal axis and the vertical axis
respectively.
\end{frame}
\begin{frame}
\frametitle{Exercise 1: Scatter plot}
\label{sec-5}
Plot a scatter plot showing the percentage profit of Company A from the year 2000
to 2010. The data for the same is available in the file \verb~company-a-data.txt~.
\end{frame}
\begin{frame}[fragile]
\frametitle{\verb~scatter()~ function}
\label{sec-6}
\begin{itemize}
\item \emph{Syntax :} scatter(x,y)
\begin{itemize}
\item x, a sequence of data
\item y, a sequence of data, the same length of x
\end{itemize}
\end{itemize}
\begin{verbatim}
In []: scatter(year, profit)
\end{verbatim}
\end{frame}
\begin{frame}[fragile]
\frametitle{Exercise 2: Scatter plot}
\label{sec-7}
Plot a scatter plot of the same data in \verb~company-a-data.txt~ with red diamond markers.
\begin{verbatim}
\end{verbatim}
\textbf{Clue} - \emph{try scatter? in your ipython interpreter}
\end{frame}
\begin{frame}
\frametitle{Pie chart}
\label{sec-8}
Pie chart - a circle graph divided into sectors, illustrating proportion.
\end{frame}
\begin{frame}[fragile]
\frametitle{Exercise 3: Pie chart}
\label{sec-9}
Plot a pie chart representing the profit percentage of company A, with the data
from the file \verb~company-a-data.txt~.
\begin{verbatim}
\end{verbatim}
\emph{(we can reuse the data in lists year and profit)}
\end{frame}
\begin{frame}[fragile]
\frametitle{\verb~pie()~ function}
\label{sec-10}
\begin{itemize}
\item \emph{Syntax :} pie(values, labels=labels)
\begin{itemize}
\item values, the data to be plotted
\item labels, the label for each wedge in the pie chart
\end{itemize}
\end{itemize}
\begin{verbatim}
In []: pie(profit, labels=year)
\end{verbatim}
\end{frame}
\begin{frame}[fragile]
\frametitle{Exercise 4: Pie chart}
\label{sec-11}
Plot a pie chart with the same data with colors for each wedges as white, red,
magenta, yellow, blue, green, cyan, yellow, magenta, and blue.
\begin{verbatim}
\end{verbatim}
\textbf{Clue} - \emph{try pie? in your ipython interpreter}
\end{frame}
\begin{frame}
\frametitle{Bar chart}
\label{sec-12}
Bar chart - a chart with rectangular bars with lengths proportional
to the values that they represent.
\end{frame}
\begin{frame}[fragile]
\frametitle{Exercise 5: Bar chart}
\label{sec-13}
Plot a bar chart representing the profit percentage of company A, with the data
from the file \verb~company-a-data.txt~.
\begin{verbatim}
\end{verbatim}
\emph{(we can reuse the data in lists year and profit)}
\end{frame}
\begin{frame}[fragile]
\frametitle{\verb~bar()~ function}
\label{sec-14}
\begin{itemize}
\item \emph{Syntax :} bar(x, y)
\begin{itemize}
\item x, a sequence of data
\item y, a sequence of data, the same length of x
\end{itemize}
\end{itemize}
\begin{verbatim}
In []: bar(year, profit)
\end{verbatim}
\end{frame}
\begin{frame}
\frametitle{Exercise 6: Bar chart}
\label{sec-15}
Plot a bar chart which is not filled and which is hatched with
$45^o$
slanting lines as shown in the image. The data for the chart may be
obtained from the file \verb~company-a-data.txt~.
\begin{center}
\includegraphics[scale=0.3]{bar-chart-hatch}
\end{center}
\textbf{Clue} - \emph{try bar? in your ipython interpreter}
\end{frame}
\begin{frame}
\frametitle{Log-log graph}
\label{sec-16}
\begin{itemize}
\item Log-log graph
\begin{itemize}
\item 2-dimensional graph.
\item uses logarithmic scales on both axes.
\item graph appears as straight line due to non-linear scaling.
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Exercise 7:}
\label{sec-17}
Plot a log-log chart of
$y = 5x^3$
for x from 1-20.
\end{frame}
\begin{frame}[fragile]
\frametitle{\verb~loglog()~ function}
\label{sec-18}
\begin{itemize}
\item \emph{Syntax :} loglog(x, y)
\begin{itemize}
\item x, a sequence of data
\item y, a sequence of data, the same length of x
\end{itemize}
\end{itemize}
\begin{verbatim}
In []: loglog(x, y)
\end{verbatim}
\end{frame}
\begin{frame}
\frametitle{Getting help on \verb~matplotlib~}
\label{sec-19}
\begin{itemize}
\item Help
\begin{itemize}
\item \hyperref[matplotlib.sourceforge.net--contents.html]{matplotlib.sourceforge.net/contents.html}
\end{itemize}
\item More plots
\begin{itemize}
\item \hyperref[matplotlib.sourceforge.net--users--screenshots.html]{matplotlib.sourceforge.net/users/screenshots.html}
\item \hyperref[matplotlib.sourceforge.net--gallery.html]{matplotlib.sourceforge.net/gallery.html}
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Summary}
\label{sec-20}
In this tutorial we learnt to,
\begin{itemize}
\item Plot a scatter plot using ``scatter()`` function
\item Plot a pie chart using ``pie()`` function
\item Plot a bar chart using ``bar()`` function
\item Plot a log-log graph using ``loglog()`` function
\item Access the \verb~matplotlib~ online help.
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Evaluation}
\label{sec-21}
\begin{enumerate}
\item ``scatter(x, y, color='blue', marker='d')`` and ``plot(x, y,
color='b', marker='d')`` does exactly the same.
\begin{itemize}
\item True
\item False
\end{itemize}
\item What statement can be issued to generate a bar chart with vertical
line hatching.
\begin{itemize}
\item bar(x, y, color='w', hatch='/')
\item bar(x, y, fill=False, hatch='//')
\item bar(x, y, fill=False, hatch='|')
\item bar(x, y, color='w', hatch='\')
\end{itemize}
\end{enumerate}
\end{frame}
\begin{frame}
\frametitle{Solutions}
\label{sec-22}
\begin{enumerate}
\item False
\item bar(x, y, fill=False, hatch='|')
\end{enumerate}
\end{frame}
\begin{frame}
\begin{block}{}
\begin{center}
\textcolor{blue}{\Large THANK YOU!}
\end{center}
\end{block}
\begin{block}{}
\begin{center}
For more Information, visit our website\\
\url{http://fossee.in/}
\end{center}
\end{block}
\end{frame}
\end{document}
|