savefig/script.rst
changeset 353 e13e3452c599
parent 319 e8c02b3c51ac
child 368 fd3c10a3d234
equal deleted inserted replaced
346:f0c93ea97e4c 353:e13e3452c599
     1 .. Objectives
     1 .. Objectives
     2 .. ----------
     2 .. ----------
     3 
     3 
     4 .. At the end of this tutorial, you will be able to 
     4 .. At the end of this tutorial, you will be able to 
     5 
     5 
     6 .. 1. Saving plots using ``savefig()`` function.
     6 .. 1. Save plots using ``savefig()`` function.
     7 .. #. Saving plots in different formats.
     7 .. #. Save plots in different formats.
     8 
     8 
     9 
     9 
    10 .. Prerequisites
    10 .. Prerequisites
    11 .. -------------
    11 .. -------------
    12 
    12 
    17 .. Author              : Anoop Jacob Thomas <anoop@fossee.in>
    17 .. Author              : Anoop Jacob Thomas <anoop@fossee.in>
    18    Internal Reviewer   : 
    18    Internal Reviewer   : 
    19    External Reviewer   :
    19    External Reviewer   :
    20    Checklist OK?       : <put date stamp here, if OK> [2010-10-05]
    20    Checklist OK?       : <put date stamp here, if OK> [2010-10-05]
    21 
    21 
       
    22 .. #[Puneeth: Quickref missing.]
    22 
    23 
    23 =======
    24 =======
    24 Savefig
    25 Savefig
    25 =======
    26 =======
    26 
    27 
    28 
    29 
    29 Hello and welcome to the tutorial saving plots.
    30 Hello and welcome to the tutorial saving plots.
    30 
    31 
    31 {{{ switch to next slide, outline slide }}}
    32 {{{ switch to next slide, outline slide }}}
    32 
    33 
    33 In this tutorial you will learn how to save plots using Python. And
    34 In this tutorial you will learn how to save plots using Python, saving
    34 saving in different formats, and locating the file in the file system.
    35 in different formats, and locating the file in the file system.
       
    36 
       
    37 .. #[Puneeth: file-system is too technical.]
    35 
    38 
    36 {{{ switch to next slide, a sine wave}}}
    39 {{{ switch to next slide, a sine wave}}}
    37 
    40 
    38 Start your IPython interpreter with the command ::
    41 Start your IPython interpreter with the command ::
    39 
    42 
    40   ipython -pylab
    43   ipython -pylab
    41 
    44 
    42 It will start your IPython interpreter with the required python
    45 As you know, it will start your IPython interpreter with the required
    43 modules for plotting and saving your plots.
    46 python modules for plotting and saving your plots.
    44 
    47 
    45 {{{ Open ipython }}}
    48 {{{ Open ipython }}}
    46 
    49 
    47 Now let us plot something, let us plot a sine wave from minus 3 pi to
    50 Now let us plot something, let us plot a sine wave from minus 3 pi to
    48 3 pi. Let us start by calculating the required points for the plot. It
    51 3 pi. Let us start by calculating the required points for the plot. It
    59 
    62 
    60 Done! we have made a very basic sine plot, now let us see how to save
    63 Done! we have made a very basic sine plot, now let us see how to save
    61 the plot for future use so that you can embed the plot in your
    64 the plot for future use so that you can embed the plot in your
    62 reports.
    65 reports.
    63 
    66 
       
    67 .. #[Puneeth: All this is known stuff. You don't have to elaborate so
       
    68 .. much on it. Just say, let us plot sin function from -3 pi to 3
       
    69 .. pi. Show the commands, and be done with it. ]
       
    70 
    64 {{{ switch to next slide, savefig() }}}
    71 {{{ switch to next slide, savefig() }}}
    65 
    72 
    66 {{{ Switch the focus to IPython interpreter window }}}
    73 {{{ Switch the focus to IPython interpreter window }}}
    67 
    74 
    68 For saving the plot, we will use ``savefig()`` function, and it has to be
    75 For saving the plot, we will use ``savefig()`` function, and it has to be
    69 done with the plot window open. The statement is, ::
    76 done with the plot window open. The statement is, ::
    70 
    77 
    71   savefig('/home/fossee/sine.png')
    78   savefig('/home/fossee/sine.png')
    72 
    79 
    73 Notice that ``savefig`` function takes one argument which is a string
    80 Notice that ``savefig`` function takes one argument which is the
    74 which is the filename. The last 3 characters after the ``.`` in the
    81 filename. The last 3 characters after the ``.`` in the filename is the
    75 filename is the extension or type of the file which determines the
    82 extension or type of the file which determines the format in which you
    76 format in which you want to save.
    83 want to save.
       
    84 
       
    85 .. #[Puneeth: removed mention of string]
    77 
    86 
    78 {{{ Highlight the /home/fossee part using mouse movements }}}
    87 {{{ Highlight the /home/fossee part using mouse movements }}}
    79 
    88 
    80 Also, note that we gave the full path or the absolute path to which we
    89 Also, note that we gave the full path or the absolute path to which we
    81 want to save the file.
    90 want to save the file.