other-type-of-plots/script.rst
changeset 354 4c09238600e0
parent 319 e8c02b3c51ac
child 369 8988867e0470
equal deleted inserted replaced
353:e13e3452c599 354:4c09238600e0
    20 .. Author              : Anoop Jacob Thomas <anoop@fossee.in>
    20 .. Author              : Anoop Jacob Thomas <anoop@fossee.in>
    21    Internal Reviewer   : 
    21    Internal Reviewer   : 
    22    External Reviewer   :
    22    External Reviewer   :
    23    Checklist OK?       : <put date stamp here, if OK> [2010-10-05]
    23    Checklist OK?       : <put date stamp here, if OK> [2010-10-05]
    24 
    24 
       
    25 .. #[Puneeth: Quickref missing]
    25 
    26 
    26 ===================
    27 ===================
    27 Other type of plots
    28 Other type of plots
    28 ===================
    29 ===================
    29 
    30 
    30 {{{ show the first slide }}}
    31 {{{ show the first slide }}}
    31 
    32 
    32 Hello and welcome to the tutorial other type of plots.
    33 Hello and welcome to the tutorial other type of plots.
    33 
    34 
       
    35 .. #[Puneeth: this sentence doesn't read well]
       
    36 
    34 {{{ show the outline slide }}}
    37 {{{ show the outline slide }}}
    35 
    38 
       
    39 .. #[Puneeth: motivate looking at other plots. Why are we looking at
       
    40 .. them? Tell that we have only looked at one type of plot all the
       
    41 .. while, etc.]
       
    42 
    36 In this tutorial we will cover scatter plot, pie chart, bar chart and
    43 In this tutorial we will cover scatter plot, pie chart, bar chart and
    37 loglog plot. We will also see few other plots and also introduce you to
    44 log-log plot. We will also see few other plots and also introduce you to
    38 the matplotlib help.
    45 the matplotlib help.
       
    46 
       
    47 .. #[Puneeth: cover, see and introduce you. be consistent. does, the
       
    48 .. "We" include the viewer or not?]
    39 
    49 
    40 Let us start with scatter plot. 
    50 Let us start with scatter plot. 
    41 
    51 
    42 {{{ switch to the next slide, scatter plot }}}
    52 {{{ switch to the next slide, scatter plot }}}
    43 
    53 
    45 each having the value of one variable determining the position on the
    55 each having the value of one variable determining the position on the
    46 horizontal axis and the value of the other variable determining the
    56 horizontal axis and the value of the other variable determining the
    47 position on the vertical axis. This kind of plot is also called a
    57 position on the vertical axis. This kind of plot is also called a
    48 scatter chart, scatter diagram and scatter graph.
    58 scatter chart, scatter diagram and scatter graph.
    49 
    59 
    50 Before we proceed further get your IPython interpreter running with
    60 Before we proceed further, start your IPython interpreter
    51 the ``-pylab`` option. Start your IPython interpreter as
       
    52 ::
    61 ::
    53 
    62 
    54     ipython -pylab
    63     ipython -pylab
    55 
    64 
    56 {{{ open the ipython interpreter in the terminal using the command
    65 {{{ open the ipython interpreter in the terminal using the command
    57 ipython -pylab }}}
    66 ipython -pylab }}}
    58 
    67 
    59 {{{ switch to the next slide having the problem statement of first
    68 {{{ switch to the next slide having the problem statement of first
    60 exercise }}}
    69 exercise }}}
    61 
    70 
    62 Now, let us plot a scatter plot showing the percentage profit of company A
    71 Now, let us plot a scatter plot showing the percentage profit of
    63 from the year 2000-2010. The data for the same is available in the
    72 company A from the year 2000-2010. The data for the same is available
    64 file ``company-a-data.txt``. 
    73 in the file ``company-a-data.txt``.
    65 
    74 
    66 {{{ open the file company-a-data.txt and show the content }}}
    75 {{{ open the file company-a-data.txt and show the content }}}
    67 
    76 
    68 The data file has two lines with a set of values in each line, the
    77 The data file has two lines with a set of values in each line, the
    69 first line representing years and the second line representing the
    78 first line representing years and the second line representing the
    76 and it can be done as ::
    85 and it can be done as ::
    77 
    86 
    78     year,profit =
    87     year,profit =
    79     loadtxt('/home/fossee/other-plot/company-a-data.txt',dtype=type(int()))
    88     loadtxt('/home/fossee/other-plot/company-a-data.txt',dtype=type(int()))
    80 
    89 
       
    90 .. #[Puneeth: make a remark about dtype, that has not been covered in
       
    91 .. the loadtxt tutorial.]
       
    92 
    81 {{{ switch to next slide, ``scatter`` function }}}
    93 {{{ switch to next slide, ``scatter`` function }}}
    82 
    94 
    83 Now in-order to generate the scatter graph we will use the function 
    95 Now in-order to generate the scatter graph we will use the function 
    84 ``scatter()`` 
    96 ``scatter()`` 
    85 ::
    97 ::
   102 
   114 
   103 .. scatter(year,profit,color='r',marker='d')
   115 .. scatter(year,profit,color='r',marker='d')
   104 
   116 
   105 Now let us move on to pie chart.
   117 Now let us move on to pie chart.
   106 
   118 
       
   119 .. #[Puneeth: instead of just saying that, say that let's plot a pie
       
   120 .. chart for the same data. continuity, will be good.]
       
   121 
   107 {{{ switch to the slide which says about pie chart }}}
   122 {{{ switch to the slide which says about pie chart }}}
   108 
   123 
   109 A pie chart or a circle graph is a circular chart divided into
   124 A pie chart or a circle graph is a circular chart divided into
   110 sectors, illustrating proportion.
   125 sectors, illustrating proportion.
   111 
   126 
   113 exercise question }}}
   128 exercise question }}}
   114 
   129 
   115 Plot a pie chart representing the profit percentage of company A, with
   130 Plot a pie chart representing the profit percentage of company A, with
   116 the same data from file ``company-a-data.txt``. So let us reuse the
   131 the same data from file ``company-a-data.txt``. So let us reuse the
   117 data we have loaded from the file previously.
   132 data we have loaded from the file previously.
       
   133 
       
   134 .. #[Puneeth, this part can be move above.]
   118 
   135 
   119 {{{ switch to next slide, ``pie()`` function }}}
   136 {{{ switch to next slide, ``pie()`` function }}}
   120 
   137 
   121 We can plot the pie chart using the function ``pie()``.
   138 We can plot the pie chart using the function ``pie()``.
   122 ::
   139 ::
   190 
   207 
   191 
   208 
   192 Plot a `log-log` chart of y=5*x\ :sup:`3` for x from 1-20.
   209 Plot a `log-log` chart of y=5*x\ :sup:`3` for x from 1-20.
   193 
   210 
   194 Before we actually plot let us calculate the points needed for
   211 Before we actually plot let us calculate the points needed for
   195 that. And it could be done as,
   212 that. 
   196 ::
   213 ::
   197 
   214 
   198     x = linspace(1,20,100)
   215     x = linspace(1,20,100)
   199     y = 5*x**3
   216     y = 5*x**3
   200 
   217