Difference between revisions of "Python/C2/Using-the-plot-command-interactively/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 1: Line 1:
 
{| border=1
 
{| border=1
!Timing
+
|'''Time'''
!Visual Cue
+
|'''Narration'''
 +
 
 
|-
 
|-
| 0:00
+
| 00:00
 
| Hello Friends and welcome to the tutorial on ''creating simple plots using iPython''.
 
| Hello Friends and welcome to the tutorial on ''creating simple plots using iPython''.
  
 
|-
 
|-
| 0:06
+
| 00:06
 
| I hope you have, IPython running on your computer.
 
| I hope you have, IPython running on your computer.
  
 
|-
 
|-
| 0:10
+
| 00:10
 
| At the end of this tutorial, you will be able to,
 
| At the end of this tutorial, you will be able to,
  
Line 18: Line 19:
  
 
|-
 
|-
0:20
+
00:20
 
| Lets start'' ipython''.
 
| Lets start'' ipython''.
  
 
|-
 
|-
| 0:22
+
| 00:22
 
| Open the terminal and type ''ipython -pylab'' and hit enter.
 
| Open the terminal and type ''ipython -pylab'' and hit enter.
  
 
|-
 
|-
| 0:35
+
| 00:35
 
| ''Pylab'' is a python library which provides plotting functionality.
 
| ''Pylab'' is a python library which provides plotting functionality.
  
 
|-
 
|-
| 0:39
+
| 00:39
 
| It provides many other important mathematical and scientific functions.
 
| It provides many other important mathematical and scientific functions.
  
 
|-
 
|-
| 0:43
+
| 00:43
 
| After running, IPython -pylab in the shell you will see some information about ipython and pylab followed by the ''In[1] prompt''
 
| After running, IPython -pylab in the shell you will see some information about ipython and pylab followed by the ''In[1] prompt''
  
 
|-
 
|-
| 0:55
+
| 00:55
 
| But if you get an error like `ERROR: ''matplotlib'' could NOT be imported!  Starting normal IPython.`
 
| But if you get an error like `ERROR: ''matplotlib'' could NOT be imported!  Starting normal IPython.`
  
 
|-
 
|-
| 1:02
+
| 01:02
 
|Then you will have to install the ''matplotlib ''and run this command again.
 
|Then you will have to install the ''matplotlib ''and run this command again.
  
 
|-
 
|-
| 1:08
+
| 01:08
 
| Now type 'linspace' followed by a '?' mark in your ipython shell
 
| Now type 'linspace' followed by a '?' mark in your ipython shell
  
 
|-
 
|-
1:19
+
01:19
 
| as the documentation says, it returns ''num'' evenly spaced samples, calculated over the interval start and stop.
 
| as the documentation says, it returns ''num'' evenly spaced samples, calculated over the interval start and stop.
  
 
|-
 
|-
| 1:29
+
| 01:29
 
| To illustrate this, lets try to generate ''100 points''.
 
| To illustrate this, lets try to generate ''100 points''.
  
 
|-
 
|-
| 1:33
+
| 01:33
 
| Type <tt>linspace within brackets ''1 comma 100 comma 100'' </tt> and hit enter.
 
| Type <tt>linspace within brackets ''1 comma 100 comma 100'' </tt> and hit enter.
  
 
|-
 
|-
| 1:47
+
| 01:47
 
| As you can see a sequence of numbers from ''1 to 100 appears.
 
| As you can see a sequence of numbers from ''1 to 100 appears.
  
 
|-
 
|-
| 1:52
+
| 01:52
 
| Now lets try to generate'' 200 points between 0 and 1''.
 
| Now lets try to generate'' 200 points between 0 and 1''.
  
 
|-
 
|-
|1:57
+
|01:57
 
|we do that by typing'' linspace'' within brackets ''0 comma 1 comma 200''.
 
|we do that by typing'' linspace'' within brackets ''0 comma 1 comma 200''.
  
 
|-
 
|-
| 2:11
+
| 02:11
 
| Here,''0'' is the start , 1 the stop and 200 the number of points.
 
| Here,''0'' is the start , 1 the stop and 200 the number of points.
  
 
|-
 
|-
| 2:18
+
| 02:18
 
| In linspace the start and stop points can be integers, decimals , or constants.  
 
| In linspace the start and stop points can be integers, decimals , or constants.  
  
 
|-  
 
|-  
| 2:24
+
| 02:24
 
|Let's try and get ''100 points between  minus pi to pi''.
 
|Let's try and get ''100 points between  minus pi to pi''.
  
 
|-
 
|-
| 2:30
+
| 02:30
 
| Here 'pi' is a constant defined by ''pylab''.
 
| Here 'pi' is a constant defined by ''pylab''.
  
 
|-
 
|-
| 2:34
+
| 02:34
 
| Save this to the variable,say ''p''.
 
| Save this to the variable,say ''p''.
  
 
|-
 
|-
| 2:52
+
| 02:52
 
| If we now type ''len'' within brackets ''p'' we will get the no. of points.
 
| If we now type ''len'' within brackets ''p'' we will get the no. of points.
  
 
|-
 
|-
| 3:05
+
| 03:05
 
| ''len'' function gives the no of elements of a sequence.
 
| ''len'' function gives the no of elements of a sequence.
  
 
|-
 
|-
| 3:11
+
| 03:11
 
| Let's try and plot a cosine curve between minus pi and pi. For this we use the plot command. Here ''cos(p)'' gets the cosine value at every point corresponding to point p.
 
| Let's try and plot a cosine curve between minus pi and pi. For this we use the plot command. Here ''cos(p)'' gets the cosine value at every point corresponding to point p.
  
 
|-
 
|-
| 3:50
+
| 03:50
 
| We can save ''cos(p)'' to variable cosine and then plot it using the plot function.
 
| We can save ''cos(p)'' to variable cosine and then plot it using the plot function.
  
 
|-
 
|-
| 3:57
+
| 03:57
 
| Now to clear the plot ,we use the ''clf'' closing brackets function
 
| Now to clear the plot ,we use the ''clf'' closing brackets function
  
 
|-
 
|-
| 4:19  
+
| 04:19  
 
| This is done, because if we wish to make another plot, it will overlap the previous plot.
 
| This is done, because if we wish to make another plot, it will overlap the previous plot.
  
 
|-
 
|-
| 4:25
+
| 04:25
 
| As we do not wish to clutter the area with overlaid plots , we just clear it with ''clf()''.  
 
| As we do not wish to clutter the area with overlaid plots , we just clear it with ''clf()''.  
  
 
|-
 
|-
|4:34
+
|04:34
 
|Now, lets try a sine plot.
 
|Now, lets try a sine plot.
  
 
|-
 
|-
| 5:04
+
| 05:04
 
| We can study the plot better on the plot window by using the various options available on it.
 
| We can study the plot better on the plot window by using the various options available on it.
  
 
|-
 
|-
| 5:11
+
| 05:11
 
| Let us have a look at these options.
 
| Let us have a look at these options.
  
 
|-
 
|-
| 5:14
+
| 05:14
 
| As we can observe, moving the mouse pointer along the plot gives us the location of each point on the plot
 
| As we can observe, moving the mouse pointer along the plot gives us the location of each point on the plot
  
 
|-
 
|-
| 5:26
+
| 05:26
 
| To the bottom left of the window,there are a few buttons.  
 
| To the bottom left of the window,there are a few buttons.  
  
 
|-
 
|-
| 5:30
+
| 05:30
 
|The right most among them is for saving the file.  
 
|The right most among them is for saving the file.  
  
 
|-
 
|-
| 5:35
+
| 05:35
 
|Just click on it and type the file name.  
 
|Just click on it and type the file name.  
  
 
|-
 
|-
| 5:48
+
| 05:48
 
|We will save the file  by the name ''sin_curve'' in pdf format.
 
|We will save the file  by the name ''sin_curve'' in pdf format.
  
 
|-
 
|-
| 6:00
+
| 06:00
 
| As you can see we can specify the format of file from the ''dropdown''.  
 
| As you can see we can specify the format of file from the ''dropdown''.  
  
 
|-
 
|-
| 6:05
+
| 06:05
 
|Formats like'' png ,eps ,pdf, ps'' are available.
 
|Formats like'' png ,eps ,pdf, ps'' are available.
  
 
|-
 
|-
| 6:17
+
| 06:17
 
| Left to the save button is the slider button by which we can specify the margins.
 
| Left to the save button is the slider button by which we can specify the margins.
  
 
|-
 
|-
| 6:25
+
| 06:25
 
| Left to this is the zoom button by which we can zoom into the plot.
 
| Left to this is the zoom button by which we can zoom into the plot.
  
 
|-
 
|-
| 6:30
+
| 06:30
 
| Just specify the region to ''zoom'' into.
 
| Just specify the region to ''zoom'' into.
  
 
|-
 
|-
| 6:40
+
| 06:40
 
| The button to the left of it can be used to move the axes of the plot.
 
| The button to the left of it can be used to move the axes of the plot.
  
 
|-
 
|-
| 6:50
+
| 06:50
 
| The next two buttons with'' left and right'' arrow icons change the state of the plot and take it to the previous state it was in.
 
| The next two buttons with'' left and right'' arrow icons change the state of the plot and take it to the previous state it was in.
  
 
|-
 
|-
| 7:00
+
| 07:00
 
| It more or less acts like the ''back and forward ''button in a browser.
 
| It more or less acts like the ''back and forward ''button in a browser.
  
 
|-
 
|-
| 7:06
+
| 07:06
 
| The last one is 'home' referring to the initial plot.
 
| The last one is 'home' referring to the initial plot.
  
 
|-
 
|-
| 7:13
+
| 07:13
 
| Pause the video here, try out the following exercise and resume the video.
 
| Pause the video here, try out the following exercise and resume the video.
  
 
|-
 
|-
| 7:20
+
| 07:20
 
|Plot ''(sin(x) into sin(x))'' by x.
 
|Plot ''(sin(x) into sin(x))'' by x.
  
 
|-
 
|-
| 7:26
+
| 07:26
 
| 1. Save the plot by the sin square by ''x.pdf ''in pdf format.
 
| 1. Save the plot by the sin square by ''x.pdf ''in pdf format.
  
 
|-
 
|-
| 7:33
+
| 07:33
 
| Second one. ''Zoom'' and find the'' maxima''.
 
| Second one. ''Zoom'' and find the'' maxima''.
  
 
|-
 
|-
| 7:37
+
| 07:37
 
| 3. Bring it back to initial position.
 
| 3. Bring it back to initial position.
 
 
  
 
|-
 
|-
| 7:44
+
| 07:44
 
| Now, lets revise quickly what we have learnt today.
 
| Now, lets revise quickly what we have learnt today.
  
 
|-
 
|-
| 7:49
+
| 07:49
 
|To Study ''Ipython'' with ''pylab''.
 
|To Study ''Ipython'' with ''pylab''.
  
 
|-
 
|-
| 7:52
+
| 07:52
 
| To Use the ''linspace ''function to create ''num'' equally spaced points in a region.
 
| To Use the ''linspace ''function to create ''num'' equally spaced points in a region.
  
 
|-
 
|-
| 7:57
+
| 07:57
 
|To Find the length of sequences using ''len'' function.
 
|To Find the length of sequences using ''len'' function.
  
 
|-
 
|-
| 8:01
+
| 08:01
 
| ''Plot'' mathematical functions using plot.
 
| ''Plot'' mathematical functions using plot.
  
 
|-
 
|-
| 8:05
+
| 08:05
 
| To clear drawing area using ''clf''.
 
| To clear drawing area using ''clf''.
  
 
|-
 
|-
| 8:08
+
| 08:08
 
| To Use the'' UI'' of plot for studying it better and using functionality like save,zoom and moving the plots on ''x and y axis''.
 
| To Use the'' UI'' of plot for studying it better and using functionality like save,zoom and moving the plots on ''x and y axis''.
  
 
|-
 
|-
| 8:23
+
| 08:23
 
| Create 100 equally spaced points between minus pi by'' 2 and pi by 2?''
 
| Create 100 equally spaced points between minus pi by'' 2 and pi by 2?''
  
 
|-
 
|-
| 8:31
+
| 08:31
 
|Second one is. How do you clear a figure in'' ipython?''
 
|Second one is. How do you clear a figure in'' ipython?''
 
  
 
|-
 
|-
| 8:36
+
| 08:36
 
|The third one. How do you find the length of a sequence?
 
|The third one. How do you find the length of a sequence?
  
 
|-
 
|-
| 8:43
+
| 08:43
 
| And the answers are,
 
| And the answers are,
  
 
|-
 
|-
| 8:45
+
| 08:45
 
|1.We use the command ''linspace within brackets minus pi by ''2 comma pi by 2 comma 100'' to create 100 equally spaced lines between the points minus pi by 2 and pi by 2''.
 
|1.We use the command ''linspace within brackets minus pi by ''2 comma pi by 2 comma 100'' to create 100 equally spaced lines between the points minus pi by 2 and pi by 2''.
  
 
|-
 
|-
| 9:03
+
| 09:03
 
|Second one. We use'' clf ''closing bracket function to clear a figure.
 
|Second one. We use'' clf ''closing bracket function to clear a figure.
  
 
|-
 
|-
| 9:11
+
| 09:11
 
|Third one. ''len within brackets sequence_name'' is the function used to find out the length of a sequence.
 
|Third one. ''len within brackets sequence_name'' is the function used to find out the length of a sequence.
 
 
  
 
|-
 
|-
| 9:20
+
| 09:20
 
| Hope you have enjoyed and found it useful.
 
| Hope you have enjoyed and found it useful.
  
 
|-
 
|-
| 9:24
+
| 09:24
 
| Thank you!
 
| Thank you!

Revision as of 12:14, 10 July 2014

Time Narration
00:00 Hello Friends and welcome to the tutorial on creating simple plots using iPython.
00:06 I hope you have, IPython running on your computer.
00:10 At the end of this tutorial, you will be able to,
  1. Create simple plots of mathematical functions.
  2. Use the Figure window to study plots better.
00:20 Lets start ipython.
00:22 Open the terminal and type ipython -pylab and hit enter.
00:35 Pylab is a python library which provides plotting functionality.
00:39 It provides many other important mathematical and scientific functions.
00:43 After running, IPython -pylab in the shell you will see some information about ipython and pylab followed by the In[1] prompt
00:55 But if you get an error like `ERROR: matplotlib could NOT be imported! Starting normal IPython.`
01:02 Then you will have to install the matplotlib and run this command again.
01:08 Now type 'linspace' followed by a '?' mark in your ipython shell
01:19 as the documentation says, it returns num evenly spaced samples, calculated over the interval start and stop.
01:29 To illustrate this, lets try to generate 100 points.
01:33 Type linspace within brackets 1 comma 100 comma 100 and hit enter.
01:47 As you can see a sequence of numbers from 1 to 100 appears.
01:52 Now lets try to generate 200 points between 0 and 1.
01:57 we do that by typing linspace within brackets 0 comma 1 comma 200.
02:11 Here,0 is the start , 1 the stop and 200 the number of points.
02:18 In linspace the start and stop points can be integers, decimals , or constants.
02:24 Let's try and get 100 points between minus pi to pi.
02:30 Here 'pi' is a constant defined by pylab.
02:34 Save this to the variable,say p.
02:52 If we now type len within brackets p we will get the no. of points.
03:05 len function gives the no of elements of a sequence.
03:11 Let's try and plot a cosine curve between minus pi and pi. For this we use the plot command. Here cos(p) gets the cosine value at every point corresponding to point p.
03:50 We can save cos(p) to variable cosine and then plot it using the plot function.
03:57 Now to clear the plot ,we use the clf closing brackets function
04:19 This is done, because if we wish to make another plot, it will overlap the previous plot.
04:25 As we do not wish to clutter the area with overlaid plots , we just clear it with clf().
04:34 Now, lets try a sine plot.
05:04 We can study the plot better on the plot window by using the various options available on it.
05:11 Let us have a look at these options.
05:14 As we can observe, moving the mouse pointer along the plot gives us the location of each point on the plot
05:26 To the bottom left of the window,there are a few buttons.
05:30 The right most among them is for saving the file.
05:35 Just click on it and type the file name.
05:48 We will save the file by the name sin_curve in pdf format.
06:00 As you can see we can specify the format of file from the dropdown.
06:05 Formats like png ,eps ,pdf, ps are available.
06:17 Left to the save button is the slider button by which we can specify the margins.
06:25 Left to this is the zoom button by which we can zoom into the plot.
06:30 Just specify the region to zoom into.
06:40 The button to the left of it can be used to move the axes of the plot.
06:50 The next two buttons with left and right arrow icons change the state of the plot and take it to the previous state it was in.
07:00 It more or less acts like the back and forward button in a browser.
07:06 The last one is 'home' referring to the initial plot.
07:13 Pause the video here, try out the following exercise and resume the video.
07:20 Plot (sin(x) into sin(x)) by x.
07:26 1. Save the plot by the sin square by x.pdf in pdf format.
07:33 Second one. Zoom and find the maxima.
07:37 3. Bring it back to initial position.
07:44 Now, lets revise quickly what we have learnt today.
07:49 To Study Ipython with pylab.
07:52 To Use the linspace function to create num equally spaced points in a region.
07:57 To Find the length of sequences using len function.
08:01 Plot mathematical functions using plot.
08:05 To clear drawing area using clf.
08:08 To Use the UI of plot for studying it better and using functionality like save,zoom and moving the plots on x and y axis.
08:23 Create 100 equally spaced points between minus pi by 2 and pi by 2?
08:31 Second one is. How do you clear a figure in ipython?
08:36 The third one. How do you find the length of a sequence?
08:43 And the answers are,
08:45 1.We use the command linspace within brackets minus pi by 2 comma pi by 2 comma 100 to create 100 equally spaced lines between the points minus pi by 2 and pi by 2.
09:03 Second one. We use clf closing bracket function to clear a figure.
09:11 Third one. len within brackets sequence_name is the function used to find out the length of a sequence.
09:20 Hope you have enjoyed and found it useful.
09:24 Thank you!

Contributors and Content Editors

Gaurav, Minal, PoojaMoolya, Sandhya.np14, Sneha