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. |