other_type_of_plots.rst
author amit
Thu, 23 Sep 2010 13:14:31 +0530
changeset 204 65e5e2362bc9
parent 161 b7c47307e510
permissions -rw-r--r--
small change in getting_started_with_lists
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
161
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
     1
.. 2.4 LO: other types of plots (3) [anoop] 
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
     2
.. -----------------------------------------
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
     3
.. * scatter 
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
     4
.. * pie chart 
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
     5
.. * bar chart 
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
     6
.. * log 
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
     7
.. * illustration of other plots, matplotlib help
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
     8
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
     9
===================
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    10
Other type of plots
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    11
===================
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    12
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    13
{{{ show the first slide }}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    14
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    15
Hello and welcome to the tutorial other type of plots.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    16
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    17
{{{ show the outline slide }}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    18
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    19
In this tutorial we will cover scatter plot, pie chart, bar chart and
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    20
log plot. We will also see few other plots and also introduce you to
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    21
the matplotlib help.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    22
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    23
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    24
Let us start with scatter plot. 
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    25
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    26
{{{ switch to the next slide }}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    27
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    28
In a scatter plot, the data is displayed as a collection of points,
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    29
each having the value of one variable determining the position on the
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    30
horizontal axis and the value of the other variable determining the
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    31
position on the vertical axis. This kind of plot is also called a
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    32
scatter chart, scatter diagram and scatter graph.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    33
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    34
Before we proceed further get your IPython interpreter running with
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    35
the ``-pylab`` option. Start your IPython interpreter as
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    36
::
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    37
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    38
    ipython -pylab
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    39
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    40
{{{ open the ipython interpreter in the terminal using the command
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    41
ipython -pylab }}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    42
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    43
{{{ switch to the next slide having the problem statement of first
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    44
exercise }}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    45
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    46
Now, let us plot a scatter plot showing the percentage profit of company A
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    47
from the year 2000-2010. The data for the same is available in the
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    48
file ``company-a-data.txt``. 
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    49
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    50
{{{ open the file company-a-data.txt and show the content }}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    51
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    52
The data file has two lines with a set of values in each line, the
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    53
first line representing years and the second line representing the
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    54
profit percentages.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    55
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    56
{{{ close the file and switch to the terminal }}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    57
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    58
To product the scatter plot first we need to load the data from the
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    59
file using ``loadtxt``. We learned in one of the previous sessions,
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    60
and it can be done as ::
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    61
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    62
    year,profit = loadtxt('/home/fossee/other-plot/company-a-data.txt',dtype=type(int()))
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    63
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    64
Now in-order to generate the scatter graph we will use the function 
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    65
``scatter()`` 
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    66
::
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    67
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    68
	scatter(year,profit)
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    69
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    70
Notice that we passed two arguments to ``scatter()`` function, first
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    71
one the values in x-coordinate, year, and the other the values in
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    72
y-coordinate, the profit percentage.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    73
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    74
{{{ switch to the next slide which has the problem statement of
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    75
problem to be tried out }}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    76
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    77
Now here is a question for you to try out, plot the same data with red
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    78
diamonds. 
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    79
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    80
**Clue** - *try scatter? in your ipython interpreter* 
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    81
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    82
.. scatter(year,profit,color='r',marker='d')
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    83
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    84
Now let us move on to pie chart.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    85
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    86
{{{ switch to the slide which says about pie chart }}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    87
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    88
A pie chart or a circle graph is a circular chart divided into
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    89
sectors, illustrating proportion.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    90
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    91
{{{ switch to the slide showing the problem statement of second
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    92
exercise question }}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    93
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    94
Plot a pie chart representing the profit percentage of company A, with
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    95
the same data from file ``company-a-data.txt``. So let us reuse the
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    96
data we have loaded from the file previously.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    97
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    98
We can plot the pie chart using the function ``pie()``.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
    99
::
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   100
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   101
   pie(profit,labels=year)
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   102
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   103
Notice that we passed two arguments to the function ``pie()``. The
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   104
first one the values and the next one the set of labels to be used in
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   105
the pie chart.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   106
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   107
{{{ switch to the next slide which has the problem statement of
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   108
problem to be tried out }}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   109
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   110
Now here is a question for you to try out, plot a pie chart with the
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   111
same data with colors for each wedges as white, red, black, magenta,
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   112
yellow, blue, green, cyan, yellow, magenta and blue respectively.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   113
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   114
**Clue** - *try pie? in your ipython interpreter* 
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   115
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   116
.. pie(t,labels=s,colors=('w','r','k','m','y','b','g','c','y','m','b'))
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   117
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   118
{{{ switch to the slide which says about bar chart }}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   119
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   120
Now let us move on to bar chart. A bar chart or bar graph is a chart
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   121
with rectangular bars with lengths proportional to the values that
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   122
they represent.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   123
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   124
{{{ switch to the slide showing the problem statement of third
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   125
exercise question }}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   126
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   127
Plot a bar chart representing the profit percentage of company A, with
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   128
the same data from file ``company-a-data.txt``. 
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   129
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   130
So let us reuse the data we have loaded from the file previously.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   131
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   132
We can plot the bar chart using the function ``bar()``.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   133
::
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   134
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   135
   bar(year,profit)
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   136
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   137
Note that the function ``bar()`` needs at least two arguments one the
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   138
values in x-coordinate and the other values in y-coordinate which is
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   139
used to determine the height of the bars.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   140
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   141
{{{ switch to the next slide which has the problem statement of
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   142
problem to be tried out }}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   143
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   144
Now here is a question for you to try, plot a bar chart which is not
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   145
filled and which is hatched with 45\ :sup:`o` slanting lines as shown
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   146
in the image in the slide.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   147
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   148
**Clue** - *try bar? in your ipython interpreter* 
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   149
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   150
.. bar(year,profit,fill=False,hatch='/')
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   151
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   152
{{{ switch to the slide which says about bar chart }}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   153
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   154
Now let us move on to log-log plot. A log-log graph or log-log plot is
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   155
a two-dimensional graph of numerical data that uses logarithmic scales
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   156
on both the horizontal and vertical axes. Because of the nonlinear
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   157
scaling of the axes, a function of the form y = ax\ :sup:`b` will
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   158
appear as a straight line on a log-log graph
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   159
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   160
{{{ switch to the slide showing the problem statement of fourth
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   161
exercise question }}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   162
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   163
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   164
Plot a `log-log` chart of y=5*x\ :sup:`3` for x from 1-20.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   165
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   166
Before we actually plot let us calculate the points needed for
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   167
that. And it could be done as,
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   168
::
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   169
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   170
    x = linspace(1,20,100)
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   171
    y = 5*x**3
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   172
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   173
Now we can plot the log-log chart using ``loglog()`` function,
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   174
::
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   175
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   176
    loglog(x,y)
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   177
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   178
To understand the difference between a normal ``plot`` and a ``log-log
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   179
plot`` let us create another plot using the function ``plot``.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   180
::
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   181
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   182
    figure(2)
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   183
    plot(x,y)
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   184
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   185
{{{ show both the plots side by side }}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   186
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   187
So that was ``log-log() plot``.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   188
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   189
{{{ switch to the next slide which says: "How to get help on
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   190
matplotlib online"}}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   191
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   192
Now we will see few more plots and also see how to access help of
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   193
matplotlib over the internet.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   194
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   195
Help about matplotlib can be obtained from
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   196
matplotlib.sourceforge.net/contents.html
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   197
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   198
.. #[[Anoop: I am not so sure how to do the rest of it, so I guess we
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   199
   can just browse through the side and tell them few. What is your
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   200
   opinion??]]
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   201
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   202
Now let us see few plots from
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   203
matplotlib.sourceforge.net/users/screenshots.html
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   204
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   205
{{{ browse through the site quickly }}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   206
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   207
{{{ switch to recap slide }}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   208
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   209
Now we have come to the end of this tutorial. We have covered scatter
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   210
plot, pie chart, bar chart, log-log plot and also saw few other plots
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   211
and covered how to access the matplotlib online help.
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   212
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   213
{{{ switch to the thank you slide }}}
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   214
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   215
Thank you!
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   216
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   217
..  Author: Anoop Jacob Thomas <anoop@fossee.in>
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   218
    Reviewer 1:
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   219
    Reviewer 2:
b7c47307e510 added dictionaries, getting started with for, other_type_of_plots and savefig.
anoop
parents:
diff changeset
   220
    External reviewer: