Difference between revisions of "Scilab/C2/Plotting-2D-graphs/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 6: Line 6:
  
 
|-
 
|-
 
 
| 00.00
 
| 00.00
 
 
| | Welcome to the spoken tutorial on Plotting 2D graphs with scilab.
 
| | Welcome to the spoken tutorial on Plotting 2D graphs with scilab.
  
 
|-
 
|-
 
+
| 00.04
| 00.05
+
 
+
 
| Assuming that Scilab is installed on your computer, we will discuss plots in Scilab.
 
| Assuming that Scilab is installed on your computer, we will discuss plots in Scilab.
  
 
|-
 
|-
 
 
|00.10
 
|00.10
 +
|Scilab offers many ways to create and customize various types of 2D and 3D plots.
  
| | Scilab offers many ways to create and customize various types of 2D and 3D plots.
+
|-
 +
|00.15
 +
|The several common charts Scilab can create are: x-y plots, contour plots, 3D plots, histograms, bar charts, etc...
  
 
|-
 
|-
 +
| 00.24
 +
|Now open your Scilab console window.
  
|00.16
+
|-
 +
|00.28
 +
|I will use Plotting.sce file to cut and paste the commands.
  
|| The several common charts Scilab can create are: x-y plots, contour plots, 3D plots, histograms, bar charts, etc...
+
|-
 +
|00.34
 +
|In order to Plot, we need a set of points. Let us create a sequence of equally spaced points.
  
 
|-
 
|-
 
+
| 00.39
| 00.25
+
| This can be done by the linspace command which creates a linearly equally spaced vector.
 
+
| | Now open your Scilab console window.
+
  
 
|-
 
|-
 
+
| 00.45
|00.28
+
|For Example
 
+
| | I will use Plotting.sce file to cut and paste the commands.
+
  
 
|-
 
|-
  
|00.34
+
|00.48
  
| | In order to Plot, we need a set of points. Let us create a sequence of equally spaced points.
+
| x is a row vector with 5 points linearly equally spaced between 1 and 10
  
 
|-
 
|-
  
| 00.40
+
| 00.57
  
| | This can be done by the linspace command which creates a linearly equally spaced vector.
+
| Similarly y is a row vector with linearly equally spaced 5 points between 1 and 20
  
 
|-
 
|-
  
| 00.46
+
|01.08
  
| | For Example
+
|| More information on linspace  can be obtained from the Help documentation.
  
 
|-
 
|-
  
|00.49
+
|01.14
  
| |x is a row vector with 5 points linearly equally spaced between 1 and 10
+
| | We will now plot a graph with the arguments x and y using the Plot function.
  
 
|-
 
|-
  
| 00.57
+
|01.19
  
| | Similarly y is a row vector with linearly equally spaced 5 points between 1 and 20
+
|| This is similar to the one used in matlab.
  
 
|-
 
|-
  
|01.08
+
| 01.23
  
|| More information on linspace command can be obtained from the Help documentation.
+
| | Plot x,y creates a graph of x verses y as you see.
  
 
|-
 
|-
  
|01.14
+
|01.31
  
| | We will now plot a graph with the arguments x and y using the Plot function.
+
| | Notice that the graphics window is labeled as '0'
  
 
|-
 
|-
  
|0119
+
| 01.36
  
|| This is similar to the one used in matlab. Plot x,y
+
| We will open another graphic window using the xset function.  
  
 
|-
 
|-
  
| 01.26
+
| 01.41
  
| |creates a graph of x verses y as you see.
+
| I will close this.
  
 
|-
 
|-
  
|01.32
+
| 01.43
  
| | Notice that the graphics window is labeled as '0' We will open another graphic window using the ,
+
| Cut the xset function, paste in scilab hit enter.
  
 
|-
 
|-
  
| 01.39
+
|01.50
  
| |xset function. I will close this cut the xset function paste in scilab hit enter.
+
| You will see a graphic window number 1.  
  
 
|-
 
|-
  
|01.51
+
|01.54
  
| You will see a graphic window number 1. Note that two arguments are passed to this function namely the window and 1.
+
| Note that two arguments are passed to this function namely the window and 1.
  
 
|-
 
|-
Line 121: Line 121:
 
|-
 
|-
  
| 02.07
+
| 02.06
  
 
|| For scilab plot 2d is the native function used to plot 2d graphs.
 
|| For scilab plot 2d is the native function used to plot 2d graphs.
Line 133: Line 133:
 
|-
 
|-
  
|02.27
+
|02.26
  
 
|| Notice that there is a third argument called style.
 
|| Notice that there is a third argument called style.
Line 139: Line 139:
 
|-
 
|-
  
| 02.32
+
| 02.31
  
 
| | Style argument is optional.It is used to customize the appearance of the plot.
 
| | Style argument is optional.It is used to customize the appearance of the plot.
Line 163: Line 163:
 
|-
 
|-
  
|02.52
+
|02.51
  
| | Also we can set the start points and end points for x and y axis by passing the fourth argument.It is called rect. As you see,
+
| | Also we can set the start points and end points for x and y axis by passing the fourth argument.
  
 
|-
 
|-
  
| 03.08
+
|02.57
  
|| We have x axis starting from 1 to 10 and y axis from 1 to 20.
+
|It is called rect. As you see,
  
 
|-
 
|-
  
| 03.15
+
| 03.07
  
| The order of argument in the rect command is xmin,ymin,xmax and ymax.
+
||  We have x axis starting from 1 to 10 and y axis from 1 to 20.
  
 
|-
 
|-
  
| 03.25
+
| 03.14
 +
 
 +
| The order of argument in the rect command is xmin, ymin, xmax and ymax.
 +
 
 +
|-
 +
 
 +
| 03.24
  
 
|| Let us now learn about Title,Axis and Legends
 
|| Let us now learn about Title,Axis and Legends
Line 205: Line 211:
 
|-
 
|-
  
|03.59
+
|03.58
 
+
| | You may want to configure the title and axis of the plot in a single command instead of 3 for this purpose we use the xtitle,
+
  
 +
| | You may want to configure the title and axis of the plot in a single command instead of 3
 
|-
 
|-
  
| 04.09
+
| 04.04
  
| |command with all the 3 arguments.
+
| |For this purpose we use the xtitle  command with all the 3 arguments.
  
 
|-
 
|-
  
| 04.12
+
| 04.11
  
 
| | I will cut this command paste in scilab enter.
 
| | I will cut this command paste in scilab enter.
Line 223: Line 228:
 
|-
 
|-
  
|04.19
+
|04.18
  
 
| | Now you see that the x axis label is X axis , Y axis and the title is My title.
 
| | Now you see that the x axis label is X axis , Y axis and the title is My title.
Line 229: Line 234:
 
|-
 
|-
  
|04.27
+
|04.26
  
 
| | The clf() function that i am typing now will clear the graphic window as you see.
 
| | The clf() function that i am typing now will clear the graphic window as you see.
Line 235: Line 240:
 
|-
 
|-
  
| 04.37
+
| 04.36
  
 
| | It is useful while plotting different graph on the same graphic window.
 
| | It is useful while plotting different graph on the same graphic window.
Line 241: Line 246:
 
|-
 
|-
  
| 04.42
+
| 04.41
  
 
| | I will close this window.
 
| | I will close this window.
Line 253: Line 258:
 
|-
 
|-
  
| 04.52
+
| 04.51
  
 
| | Let us see an example for this I will scroll down
 
| | Let us see an example for this I will scroll down
Line 259: Line 264:
 
|-
 
|-
  
|04.57
+
|04.56
  
 
|| We will define the x axis points in a row vector x using the linspace command
 
|| We will define the x axis points in a row vector x using the linspace command
Line 273: Line 278:
 
| 05.05
 
| 05.05
  
| |y1 = x^2
+
| |y1 = x square
  
 
|-
 
|-
  
| 05.08
+
| 05.07
  
 
| |plot x verses y1
 
| |plot x verses y1
Line 285: Line 290:
 
|05.10
 
|05.10
  
| | define another function
+
| | define another function y2 = 2x square
  
|-
 
 
|05.12
 
 
| |y2 = 2*x^2
 
  
 
|-
 
|-
 
 
|05.15
 
|05.15
 
 
| |plot x verses y2
 
| |plot x verses y2
  
 
|-
 
|-
  
| 05.19
+
| 05.17
  
| | we will also give label and title to our graph
+
| | We will also give label and title to our graph
  
 
|-
 
|-
  
|05.23
+
|05.22
  
|| Notice that we have additionally passed ”o-” and ”+-” commands to the plot function, to change the appearance of the curve
+
|| Notice that we have additionally passed ”o-” and ”+ -” commands to the plot function, to change the appearance of the curve
  
 
|-
 
|-
Line 337: Line 335:
 
|-
 
|-
  
| 05.52
+
| 05.51
  
 
| | Wouldn't it be of great help to know which curve is associated with which function?
 
| | Wouldn't it be of great help to know which curve is associated with which function?
Line 343: Line 341:
 
|-
 
|-
  
| 05.57
+
| 05.56
  
|| This can be achieved using the legend command as you see
+
|| This can be achieved using the legend commandas you see
  
 
|-
 
|-
  
| 06.09
+
| 06.08
  
|| "o-" curve represents function y1=x^2 and "+-" curve represents function y2=2*x^2
+
|| "o-" curve represents function y1=x square  and "+-" curve represents function y2=2*x^2 (y2=2x square)
  
 
|-
 
|-
  
| 06.20
+
| 06.19
  
 
|| I will close this graphic window
 
|| I will close this graphic window
Line 361: Line 359:
 
|-
 
|-
  
| 06.23
+
| 06.22
  
 
| | We will now discuss about plot2d demos and subplot function
 
| | We will now discuss about plot2d demos and subplot function
Line 369: Line 367:
 
| 06.28
 
| 06.28
  
| | Scilab provides demos for all its major functions Demos of plot2d can be viewed through demonstration tab.
+
| | Scilab provides demos for all its major functions.  
  
 
|-
 
|-
  
|06.40
+
| 06.31
  
| | click on Graphics,click 2d_3d plots and select a demo out of the various demos provided. I will click on plot2d.
+
| Demos of plot2d can be viewed through the demonstration tab.
 +
 
 +
|-
 +
 
 +
|06.39
 +
 
 +
| | Click on Graphics, click 2d_3d plots and select a demo out of the various demos provided.  
 +
 
 +
|-
 +
 
 +
|06.51
 +
 
 +
| I will click on plot2d.
  
 
|-
 
|-
Line 385: Line 395:
 
|-
 
|-
  
|06.56
+
|06.55
  
 
|| The code for this graph can also be seen by clicking on the view code button here.
 
|| The code for this graph can also be seen by clicking on the view code button here.
Line 393: Line 403:
 
| 07.02
 
| 07.02
  
| | This link does not open in Mac OS but works in windows and linux
+
| | This link does not open in Mac OS but it works in windows and linux
  
 
|-
 
|-
  
| 07.08
+
| 07.07
  
| | Nevertheless in Mac the code can be viewed through the directory.
+
| | Never the less in Mac the code can be viewed through the directory.
  
 
|-
 
|-
Line 409: Line 419:
 
|-
 
|-
  
|07.16
+
|07.15
  
| | currently i am in demos directory of scilab 5.2 as shown.
+
| | Currently i am in demos directory of scilab 5.2 as shown.
  
 
|-
 
|-
  
| 07.22
+
| 07.21
  
 
| | The full path to this directory is shown here.
 
| | The full path to this directory is shown here.
Line 421: Line 431:
 
|-
 
|-
  
|07.28
+
|07.27
  
|| we will type ls to see the list of demos available as you see here.
+
|| We will type ls to see the list of demos availableas you see here.
  
|
 
  
 
|-
 
|-
  
| 07.37
+
| 07.36
  
| Then we will select the 2d_3d_plots directory and hit enter type ls again to see various demo code available in the sce files
+
| Then we will select the 2d_3d_plots directory and hit enter.
 +
 
 +
|-
 +
 
 +
| 07.46
 +
 
 +
| Type ls again to see the various demo code available in the sce files
  
 
|-
 
|-
Line 447: Line 462:
 
|-
 
|-
  
|08.12
+
|08.11
  
 
|| Here you will see the code for the demo graph of plot2d function
 
|| Here you will see the code for the demo graph of plot2d function
Line 455: Line 470:
 
| 08.18
 
| 08.18
  
| | I will close the terminal I will close the demo graph and the demo window
+
| | I will close the terminal.
 +
 
 +
|-
 +
 
 +
| 08.21
 +
 
 +
|I will close the demo graph and the demo window
 +
 
  
 
|-
 
|-
Line 465: Line 487:
 
|-
 
|-
  
|08.30
+
|08.29
  
 
| | Let us now discuss about Subplot function
 
| | Let us now discuss about Subplot function
Line 477: Line 499:
 
|-
 
|-
  
| 08.38
+
| 08.37
  
 
| | To explain this function we will use demos for plotting 2D graphs in scilab.
 
| | To explain this function we will use demos for plotting 2D graphs in scilab.
Line 487: Line 509:
 
| |For example, type plot 2d in your console and see the demo plot for this function
 
| |For example, type plot 2d in your console and see the demo plot for this function
  
|
 
  
 
|-
 
|-
  
| 08.59
+
| 08.58
  
 
| | I will close this window.
 
| | I will close this window.
Line 497: Line 518:
 
|-
 
|-
  
| 09.01
+
| 09.00
  
 
| The subplot command breaks the graphics window into a 2 by 2 matrix of sub-windows represented by the first two arguments in the subplot command.
 
| The subplot command breaks the graphics window into a 2 by 2 matrix of sub-windows represented by the first two arguments in the subplot command.
Line 503: Line 524:
 
|-
 
|-
  
| 09.11
+
| 09.10
  
 
| |The third argument denotes the current window in which the plot will be plotted
 
| |The third argument denotes the current window in which the plot will be plotted
Line 509: Line 530:
 
|-
 
|-
  
| 09.16
+
| 09.15
  
 
|| I will execute this whole set of commands by copying it to the scilab console
 
|| I will execute this whole set of commands by copying it to the scilab console
Line 515: Line 536:
 
|-
 
|-
  
|09.25
+
|09.24
  
 
| | You can see 4 plots in a single plot window .
 
| | You can see 4 plots in a single plot window .
Line 521: Line 542:
 
|-
 
|-
  
| 09.29
+
| 09.28
  
 
| | The plot obtained can be saved as a image on your computer
 
| | The plot obtained can be saved as a image on your computer
Line 527: Line 548:
 
|-
 
|-
  
| 09.33
+
| 09.32
  
 
| Click on the graphic window, go to File menu select export to .
 
| Click on the graphic window, go to File menu select export to .
Line 533: Line 554:
 
|-
 
|-
  
| 09.40
+
| 09.39
 +
 
 +
| | Give a suitable title to your plot,
 +
 
 +
|-
 +
 
 +
| 09.50
 +
 
 +
| Select a destination folder to save your file. 
 +
 
 +
|-
 +
 
 +
| 09.54
  
| | Give a suitable title to your plot, select a destination folder to save your file select the file format in which you want your image to appear.
+
|Select the file format in which you want your image to appear.
  
 
|-
 
|-
  
| 10.59
+
| 09.59
  
 
| | I will select the JPEG format and Click Save.
 
| | I will select the JPEG format and Click Save.
Line 551: Line 584:
 
|-
 
|-
  
| 10.12
+
| 10.11
  
 
| | This brings us to the end of this spoken tutorial on Plotting in Scilab.
 
| | This brings us to the end of this spoken tutorial on Plotting in Scilab.
Line 557: Line 590:
 
|-
 
|-
  
|10.16
+
|10.15
  
 
|| There are many other functions in Scilab which will be covered in other spoken tutorials.
 
|| There are many other functions in Scilab which will be covered in other spoken tutorials.
Line 569: Line 602:
 
|-
 
|-
  
|10.23
+
|10.22
  
 
| Spoken Tutorials are part of the Talk to a Teacher project, supported by the National Mission on Education through ICT.
 
| Spoken Tutorials are part of the Talk to a Teacher project, supported by the National Mission on Education through ICT.
Line 577: Line 610:
 
|10.29
 
|10.29
  
| | More information on the same is availableon the following link
+
| | More information on the same is available on the following link
  
 
|-
 
|-
  
|10.33
+
|10.32
  
 
| |Thanks for joining. Good bye
 
| |Thanks for joining. Good bye
  
 
|}
 
|}

Revision as of 11:11, 7 March 2014

Time Narration
00.00 Welcome to the spoken tutorial on Plotting 2D graphs with scilab.
00.04 Assuming that Scilab is installed on your computer, we will discuss plots in Scilab.
00.10 Scilab offers many ways to create and customize various types of 2D and 3D plots.
00.15 The several common charts Scilab can create are: x-y plots, contour plots, 3D plots, histograms, bar charts, etc...
00.24 Now open your Scilab console window.
00.28 I will use Plotting.sce file to cut and paste the commands.
00.34 In order to Plot, we need a set of points. Let us create a sequence of equally spaced points.
00.39 This can be done by the linspace command which creates a linearly equally spaced vector.
00.45 For Example
00.48 x is a row vector with 5 points linearly equally spaced between 1 and 10
00.57 Similarly y is a row vector with linearly equally spaced 5 points between 1 and 20
01.08 More information on linspace can be obtained from the Help documentation.
01.14 We will now plot a graph with the arguments x and y using the Plot function.
01.19 This is similar to the one used in matlab.
01.23 Plot x,y creates a graph of x verses y as you see.
01.31 Notice that the graphics window is labeled as '0'
01.36 We will open another graphic window using the xset function.
01.41 I will close this.
01.43 Cut the xset function, paste in scilab hit enter.
01.50 You will see a graphic window number 1.
01.54 Note that two arguments are passed to this function namely the window and 1.
02.03 The next graph will be plotted on this window.
02.06 For scilab plot 2d is the native function used to plot 2d graphs.
02.14 plot2d command plots a graph of x verses y as you see.
02.26 Notice that there is a third argument called style.
02.31 Style argument is optional.It is used to customize the appearance of the plot.
02.36 For positive values of style the curve is a plain with different colours like green for 3 in our case.
02.44 The default value of style is 1.
02.46 Try plotting graphs for negative values and see the difference in appearance yourself.
02.51 Also we can set the start points and end points for x and y axis by passing the fourth argument.
02.57 It is called rect. As you see,
03.07 We have x axis starting from 1 to 10 and y axis from 1 to 20.
03.14 The order of argument in the rect command is xmin, ymin, xmax and ymax.
03.24 Let us now learn about Title,Axis and Legends
03.28 To configure labels to the axis and title to the plot we can use the commands title, x label and ylabel.
03.38 I will cut this set of commands and paste in the console. Hit enter
03.45 You will see that the graph has been labeled x to the x axis, y to the y axis and the title of the graph is my title.
03.58 You may want to configure the title and axis of the plot in a single command instead of 3
04.04 For this purpose we use the xtitle command with all the 3 arguments.
04.11 I will cut this command paste in scilab enter.
04.18 Now you see that the x axis label is X axis , Y axis and the title is My title.
04.26 The clf() function that i am typing now will clear the graphic window as you see.
04.36 It is useful while plotting different graph on the same graphic window.
04.41 I will close this window.
04.44 Sometimes we need to compare two sets of data in the same plot, that is, one set of x data and two sets of y data.
04.51 Let us see an example for this I will scroll down
04.56 We will define the x axis points in a row vector x using the linspace command
05.03 Let us define a function
05.05 y1 = x square
05.07 plot x verses y1
05.10 define another function y2 = 2x square


05.15 plot x verses y2
05.17 We will also give label and title to our graph
05.22 Notice that we have additionally passed ”o-” and ”+ -” commands to the plot function, to change the appearance of the curve
05.33 These arguments are not a part of the plot2d function.
05.37 They can be used only with the plot function
05.41 I will copy these set of commands and paste in the scilab console.
05.49 You see the graph
05.51 Wouldn't it be of great help to know which curve is associated with which function?
05.56 This can be achieved using the legend command, as you see
06.08 "o-" curve represents function y1=x square and "+-" curve represents function y2=2*x^2 (y2=2x square)
06.19 I will close this graphic window
06.22 We will now discuss about plot2d demos and subplot function
06.28 Scilab provides demos for all its major functions.
06.31 Demos of plot2d can be viewed through the demonstration tab.
06.39 Click on Graphics, click 2d_3d plots and select a demo out of the various demos provided.
06.51 I will click on plot2d.
06.54 You will see the demo graph
06.55 The code for this graph can also be seen by clicking on the view code button here.
07.02 This link does not open in Mac OS but it works in windows and linux
07.07 Never the less in Mac the code can be viewed through the directory.
07.12 Let us go to the terminal.
07.15 Currently i am in demos directory of scilab 5.2 as shown.
07.21 The full path to this directory is shown here.
07.27 We will type ls to see the list of demos available, as you see here.


07.36 Then we will select the 2d_3d_plots directory and hit enter.
07.46 Type ls again to see the various demo code available in the sce files
07.55 we will view the code for the demo which we have seen earlier.
08.00 Type more plot2d.dem.sce and hit enter
08.11 Here you will see the code for the demo graph of plot2d function
08.18 I will close the terminal.
08.21 I will close the demo graph and the demo window


08.26 Similarly you can go through the other demos and explore scilab
08.29 Let us now discuss about Subplot function
08.33 The subplot() function divides the graphics window into a matrix of sub-windows.
08.37 To explain this function we will use demos for plotting 2D graphs in scilab.
08.43 For example, type plot 2d in your console and see the demo plot for this function


08.58 I will close this window.
09.00 The subplot command breaks the graphics window into a 2 by 2 matrix of sub-windows represented by the first two arguments in the subplot command.
09.10 The third argument denotes the current window in which the plot will be plotted
09.15 I will execute this whole set of commands by copying it to the scilab console
09.24 You can see 4 plots in a single plot window .
09.28 The plot obtained can be saved as a image on your computer
09.32 Click on the graphic window, go to File menu select export to .
09.39 Give a suitable title to your plot,
09.50 Select a destination folder to save your file.
09.54 Select the file format in which you want your image to appear.
09.59 I will select the JPEG format and Click Save.
10.05 Browse through the directory to open the image and verify yourself whether it has been saved or not.
10.11 This brings us to the end of this spoken tutorial on Plotting in Scilab.
10.15 There are many other functions in Scilab which will be covered in other spoken tutorials.
10.20 Keep watching the Scilab links.
10.22 Spoken Tutorials are part of the Talk to a Teacher project, supported by the National Mission on Education through ICT.
10.29 More information on the same is available on the following link
10.32 Thanks for joining. Good bye

Contributors and Content Editors

Gaurav, Krupali, PoojaMoolya, Sandhya.np14, Sneha