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

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 5: Line 5:
 
|-
 
|-
 
| 00:00
 
| 00:00
| Hello and welcome to the tutorial on "Saving plots".
+
| Hello and welcome to the tutorial on '''"Saving plots"'''.
  
 
|-
 
|-
 
| 00:04
 
| 00:04
| 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 savefig()function.
+
# '''Save''' plots using '''savefig()''' function.
# Save plots in different formats.
+
# Save '''plot'''s in different formats.
  
 
|-
 
|-
 
| 00:13
 
| 00:13
| Before beginning this tutorial,we would suggest you to complete the tutorial on "Using plot interactively".
+
| Before beginning this tutorial, we would suggest you to complete the tutorial on '''"Using plot interactively"'''.
  
 
|-
 
|-
 
|00:19
 
|00:19
|Now, Start your IPython interpreter with the command ipython hyphen pylab
+
|Now, start your '''IPython interpreter''' with the command '''ipython hyphen pylab'''.
  
 
|-
 
|-
 
|00:30
 
|00:30
|As you know, it will start your IPython interpreter with the required python modules for plotting and saving your plots.
+
|As you know, it will start your IPython interpreter with the required '''python module'''s for plotting and saving your plots.
  
 
|-
 
|-
 
| 00:36
 
| 00:36
| To start with, let us plot a sine wave from minus 3 pi to 3 pi.
+
| To start with, let us plot a '''sine wave''' from '''minus 3 pi to 3 pi'''.
  
 
|-
 
|-
Line 36: Line 36:
 
|-
 
|-
 
| 00:45
 
| 00:45
| It can be done using linspace as,
+
| It can be done using '''linspace''' as-
  
 
|-
 
|-
 
|00:51
 
|00:51
|You can Type x = linspace within brackets minus 3 into pi comma 3 into pi comma 100  
+
|You can type: '''x = linspace''' within brackets '''minus 3 into pi comma 3 into pi comma 100'''.
  
 
|-
 
|-
 
|  00:59
 
|  00:59
| We have stored the required points in x.  
+
| We have stored the required points in 'x'.  
  
 
|-
 
|-
 
|01:03
 
|01:03
|Now let us plot the points using the plot statement.So type plot (x,sinx)   
+
|Now, let us plot the points using the ''''plot' statement'''. So, type: '''plot (x, sinx)'''.  
  
 
|-
 
|-
Line 56: Line 56:
 
|-
 
|-
 
| 01:19
 
| 01: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.
+
| 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 '''report'''s.
  
 
|-
 
|-
 
| 01:32
 
| 01:32
| So saving the plot, we will use savefig() function.  
+
| So, saving the plot, we will use '''savefig()''' function.  
  
 
|-
 
|-
 
|01:36
 
|01:36
|For this we shall keep the plot window open alongside the terminal.
+
|For this, we shall keep the '''plot window''' open alongside the '''terminal'''.
  
 
|-
 
|-
 
|01:40
 
|01:40
| The statement is savefig within brackets in single quotes slash home slash fossee slash sine dot png
+
| The statement is: '''savefig''' within brackets in single quotes '''slash home slash fossee slash sine dot png'''.
  
 
|-
 
|-
 
| 01:52
 
| 01: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.
+
| 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'''.
  
 
|-
 
|-
 
| 02:10
 
| 02:10
| Also, note that we gave the full path or the absolute path to which we want to save the file.
+
| Also, note that we gave the full '''path''' or the '''absolute path''' to which we want to save the file.
  
 
|-
 
|-
 
| 02:18
 
| 02:18
| Here we have used an extension dot png 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'''.
  
 
|-
 
|-
 
|02:25
 
|02:25
|Now let us locate the file sine dot png which we had saved a while ago.
+
|Now, let us locate the file '''sine dot png''' which we had saved a while ago.
  
 
|-
 
|-
 
| 02:32
 
| 02:32
| We have saved the file to slash home slash fossee so let us navigate to  slash home slash fossee using thefile browser.
+
| We have saved the file to '''slash home slash fossee'''. So, let us navigate to  '''slash home slash fossee''' using the file browser.
  
 
|-
 
|-
 
| 02:49
 
| 02:49
| Yes, the file sine dot png  is here.  
+
| Yes, the file '''sine dot png''' is here.  
  
 
|-
 
|-
 
| 02:52
 
| 02:52
| Let us open it and check
+
| Let us open it and check.
  
 
|-
 
|-
 
|  02:57
 
|  02:57
| So in-order to save a plot , we use savefig function.
+
| So, in-order to save a plot, we use '''savefig()''' function.
  
 
|-
 
|-
 
| 03:05
 
| 03: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.
+
| '''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 112: Line 117:
 
|-
 
|-
 
|03:29
 
|03:29
|Save the sine plot in the EPS format which can be embedded in LaTeX documents.
+
|Save the '''sine plot''' in the '''EPS format''' which can be embedded in '''LaTeX document'''s.
  
 
|-
 
|-
 
| 03:37
 
| 03:37
| We still have the sine plot with us,let us now save the plot as sine dot eps.
+
| We still have the '''sine plot''' with us, let us now '''save''' the plot as '''sine dot eps'''.
  
 
|-
 
|-
 
| 03:49
 
| 03: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
+
| 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'''.
  
 
|-
 
|-
 
| 04:04
 
| 04:04
| Now let us go to slash home slash fossee  and see the new file created.
+
| Now, let us go to: '''slash home slash fossee''' and see the new file created.
  
 
|-
 
|-
 
| 04:13
 
| 04:13
| Yes! the new file sine dot epsis here.
+
| Yes! the new file '''sine dot eps''' is here.
  
 
|-
 
|-
Line 136: Line 141:
 
|-
 
|-
 
|04:23
 
|04:23
|Save the sine plot in PDF, PS and SVG formats.
+
|Save the '''sine plot''' in '''PDF, PS''' and '''SVG format'''s.
  
 
|-
 
|-
Line 144: Line 149:
 
|-
 
|-
 
|04:34
 
|04:34
|In this tutorial,we have learnt to, Save plots using the savefig() function.
+
|In this tutorial, we have learnt to save plots using the '''savefig()''' function.
  
 
|-
 
|-
 
| 04:38
 
| 04:38
| then Save the plots in different formats like - pdf - ps - png - svg - eps
+
| Then save the plots in different formats like - '''pdf, ps, png, svg, eps.'''
  
 
|-
 
|-
 
| 04:45
 
| 04:45
| Here are some self assessment questions for you to solve
+
| Here are some self assessment questions for you to solve-
  
 
|-
 
|-
 
|04:48
 
|04:48
|1. Which command is used to save a plot. saveplot() savefig() savefigure() saveplt()
+
|1. Which command is used to save a plot. '''saveplot(), savefig(), savefigure(), saveplt()'''?
  
 
|-
 
|-
 
|04:59
 
|04:59
| 2. savefig('sine.png') saves the plot in,
+
| 2. '''savefig('sine.png')''' saves the plot in-
  
 
|-
 
|-
 
| 05:04
 
| 05:04
| The root directory (on GNU/Linux, Unix based systems), c colon slash (on windows).
+
| The '''root''' directory (on GNU/Linux, Unix based systems)- '''c colon slash''' (on windows).
  
 
|-
 
|-
 
| 05:14
 
| 05:14
| The second option. Will result in an error as full path is not supplied.
+
| The second option- Will result in an error as full path is not supplied.
  
 
|-
 
|-
 
| 05:18
 
| 05:18
| The third one.The current working directory.
+
| The third one- The current working directory.
  
 
|-
 
|-
 
| 05:21
 
| 05:21
| and final option is Predefined directory like /documents.
+
| and final option is- Predefined directory like "/documents".
  
 
|-
 
|-
 
|05:26
 
|05:26
| And now, the answers,
+
| And now, the answers-
  
 
|-
 
|-
 
| 05:28
 
| 05:28
|1.To save a plot,we use the savefig() function.
+
|1. To save a plot, we use the '''savefig()''' function.
  
 
|-
 
|-
 
|05:33
 
|05:33
|2. Whenever we save a file,it gets saved in the current working directory.
+
|2. Whenever we save a file, it gets saved in the current working directory.
  
 
|-
 
|-
 
| 05:38
 
| 05:38
| Hope you have enjoyed and found it useful.THanks
+
| Hope you have enjoyed and found it useful. Thanks.

Revision as of 08:54, 31 October 2015

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

Contributors and Content Editors

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