Difference between revisions of "Python/C2/Saving-plots/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with '{| border=1 !Timing !Narration |- | 0:00 | Hello and welcome to the tutorial on "Saving plots". |- | 0:04 | At the end of this tutorial, you will be able to, # Save plots using…')
 
Line 10: Line 10:
 
| At the end of this tutorial, you will be able to,
 
| At the end of this tutorial, you will be able to,
  
# Save plots using <tt>savefig()</tt> function.
+
# Save plots using savefig()function.
 
# Save plots in different formats.
 
# Save plots in different formats.
  
Line 19: Line 19:
 
|-
 
|-
 
|0:19
 
|0:19
|Now, <nowiki>Start your IPython interpreter with the command ipython hyphen pylab <Pause></nowiki>
+
|Now, Start your IPython interpreter with the command ipython hyphen pylab <Pause>
  
 
|-
 
|-
Line 59: Line 59:
 
|-
 
|-
 
| 1:32
 
| 1:32
| For saving the plot, we will use <tt>savefig()</tt> function.  
+
| For saving the plot, we will use savefig() function.  
  
 
|-
 
|-
Line 71: Line 71:
 
|-
 
|-
 
| 1:52
 
| 1:52
| Notice that <tt>savefig</tt> function takes one argument which is the filename, the last 3 characters after the <tt>.</tt> in the filename is the extension and type of the file which determines the format in which you want to save.
+
| Notice that savefig function takes one argument which is the filename, the last 3 characters after the. in the filename is the extension and type of the file which determines the format in which you want to save.
  
 
|-
 
|-
Line 79: Line 79:
 
|-
 
|-
 
| 2:18
 
| 2:18
| Here we have used an extension <tt>dot png</tt> which means we want to save the image as a PNG file.
+
| Here we have used an extension dot png which means we want to save the image as a PNG file.
  
 
|-
 
|-
 
|2:25
 
|2:25
|Now let us locate the file <tt>sine dot png</tt> which we had saved a while ago.
+
|Now let us locate the file sine dot png which we had saved a while ago.
  
 
|-
 
|-
 
| 2:32
 
| 2:32
| We have saved the file to <tt> slash home slash fossee</tt> so let us navigate to <tt>slash home slash fossee</tt> using thefile browser.
+
| We have saved the file to slash home slash fossee so let us navigate to slash home slash fossee using thefile browser.
  
 
|-
 
|-
 
| 2:49
 
| 2:49
| Yes, the file <tt>sine dot png</tt> is here.  
+
| Yes, the file sine dot png is here.  
  
 
|-
 
|-
Line 99: Line 99:
 
|-
 
|-
 
|  2:57
 
|  2:57
| So in-order to save a plot, we use <tt>savefig</tt> function.
+
| So in-order to save a plot, we use savefig function.
  
 
|-
 
|-
 
| 3:05
 
| 3:05
| <tt>dot savefig</tt> can save the plot in many formats, such as pdf - portable document format, ps - post script, eps - encapsulated post script, svg - scalable vector graphics, png - portable network graphics which support transparency etc.
+
| dot savefig can save the plot in many formats, such as pdf - portable document format, ps - post script, eps - encapsulated post script, svg - scalable vector graphics, png - portable network graphics which support transparency etc.
  
 
|-
 
|-
Line 115: Line 115:
 
|-
 
|-
 
| 3:37
 
| 3:37
| We still have the sine plot with us,let us now save the plot as <tt>sine dot eps</tt>.
+
| We still have the sine plot with us,let us now save the plot as sine dot eps.
  
 
|-
 
|-
 
| 3:49
 
| 3:49
| Now, We will save the plot using the function <tt>savefig</tt>, so you can type savefig within brackets in single quotes slash home slash fossee slash sine dot eps and hit enter
+
| Now, We will save the plot using the function savefig, so you can type savefig within brackets in single quotes slash home slash fossee slash sine dot eps and hit enter
  
 
|-
 
|-
 
|  4:04
 
|  4:04
| Now let us go to <tt>slash home slash fossee</tt> and see the new file created.
+
| Now let us go to slash home slash fossee and see the new file created.
  
 
|-
 
|-
 
| 4:13
 
| 4:13
| Yes! the new file <tt>sine dot eps</tt> is here.
+
| Yes! the new file sine dot epsis here.
  
 
|-
 
|-
Line 143: Line 143:
 
|-
 
|-
 
|4:34
 
|4:34
|In this tutorial,we have learnt to, Save plots using the <tt>savefig()</tt> function.
+
|In this tutorial,we have learnt to, Save plots using the savefig() function.
  
 
|-
 
|-
Line 159: Line 159:
 
|-
 
|-
 
|4:59
 
|4:59
| 2. <tt>savefig('sine.png')</tt> saves the plot in,
+
| 2. savefig('sine.png') saves the plot in,
  
 
|-
 
|-
 
| 5:04
 
| 5:04
| The root directory <tt>/</tt> (on GNU/Linux, Unix based systems), <tt>c colon slash </tt> (on windows).
+
| The root directory (on GNU/Linux, Unix based systems), c colon slash (on windows).
  
 
|-
 
|-
Line 175: Line 175:
 
|-
 
|-
 
| 5:21
 
| 5:21
| and final option is Predefined directory like <tt>/documents</tt>.
+
| and final option is Predefined directory like /documents.
  
 
|-
 
|-
Line 183: Line 183:
 
|-
 
|-
 
| 5:28
 
| 5:28
|1.To save a plot,we use the <tt>savefig()</tt> function.
+
|1.To save a plot,we use the savefig() function.
  
 
|-
 
|-

Revision as of 15:38, 7 March 2013

Timing Narration
0:00 Hello and welcome to the tutorial on "Saving plots".
0:04 At the end of this tutorial, you will be able to,
  1. Save plots using savefig()function.
  2. Save plots in different formats.
0:13 Before beginning this tutorial,we would suggest you to complete the tutorial on "Using plot interactively".
0:19 Now, Start your IPython interpreter with the command ipython hyphen pylab <Pause>
0:30 As you know, it will start your IPython interpreter with the required python modules for plotting and saving your plots.
0:36 To start with, let us plot a sine wave from minus 3 pi to 3 pi.
0:43 Let us start by calculating the required points for the plot.
0:45 It can be done using linspace as,
0:51 Type x = linspace within brackets minus 3 into pi comma 3 into pi comma 100
0:59 We have stored the required points in x.
1:03 Now let us plot the points using the plot statement.
1:18 Done!
1:19 we have made a very basic sine plot, now let us see how to save the plot for future use so that you can embed the plot in your reports.
1:32 For saving the plot, we will use savefig() function.
1:36 For this we shall keep the plot window open alongside the terminal.
1:40 The statement is,savefig within brackets in single quotes slash home slash fossee slash sine dot png
1:52 Notice that savefig function takes one argument which is the filename, the last 3 characters after the. in the filename is the extension and type of the file which determines the format in which you want to save.
2:10 Also, note that we gave the full path or the absolute path to which we want to save the file.
2:18 Here we have used an extension dot png which means we want to save the image as a PNG file.
2:25 Now let us locate the file sine dot png which we had saved a while ago.
2:32 We have saved the file to slash home slash fossee so let us navigate to slash home slash fossee using thefile browser.
2:49 Yes, the file sine dot png is here.
2:52 Let us open it and check.
2:57 So in-order to save a plot, we use savefig function.
3:05 dot savefig can save the plot in many formats, such as pdf - portable document format, ps - post script, eps - encapsulated post script, svg - scalable vector graphics, png - portable network graphics which support transparency etc.
3:24 Pause the video here, try out the following exercise and resume the video.
3:29 Save the sine plot in the EPS format which can be embedded in LaTeX documents.
3:37 We still have the sine plot with us,let us now save the plot as sine dot eps.
3:49 Now, We will save the plot using the function savefig, so you can type savefig within brackets in single quotes slash home slash fossee slash sine dot eps and hit enter
4:04 Now let us go to slash home slash fossee and see the new file created.
4:13 Yes! the new file sine dot epsis here.
4:18 Pause the video here, try out the following exercise and resume the video.
4:23 Save the sine plot in PDF, PS and SVG formats.
4:31 This brings us to the end of this tutorial.
4:34 In this tutorial,we have learnt to, Save plots using the savefig() function.
4:38 then Save the plots in different formats like - pdf - ps - png - svg - eps
4:45 Here are some self assessment questions for you to solve
4:48 1. Which command is used to save a plot. saveplot() savefig() savefigure() saveplt()
4:59 2. savefig('sine.png') saves the plot in,
5:04 The root directory (on GNU/Linux, Unix based systems), c colon slash (on windows).
5:14 The second option. Will result in an error as full path is not supplied.
5:18 The third one.The current working directory.
5:21 and final option is Predefined directory like /documents.
5:26 And now, the answers,
5:28 1.To save a plot,we use the savefig() function.
5:33 2. Whenever we save a file,it gets saved in the current working directory.
5:38 Hope you have enjoyed and found it useful.

Contributors and Content Editors

Gaurav, Jyotisolanki, Minal, PoojaMoolya, Sandhya.np14, Sneha