Difference between revisions of "Gnuplot/C2/Plotting-functions/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "'''Title of script''': '''Plotting functions''' '''Author: '''Rani Parvathy '''Keywords:''' Video tutorial, spoken tutorial, gnuplot, sin (x), cos(x), graph, plot, replot, a...")
 
Line 1: Line 1:
'''Title of script''': '''Plotting functions'''
+
{|border=1
 +
||'''Visual Cue'''
 +
||'''Narration'''
  
'''Author: '''Rani Parvathy
 
 
'''Keywords:''' Video tutorial, spoken tutorial, gnuplot, sin (x), cos(x), graph, plot, replot, axis range, angle, Greek alphabet, font style, help documentation, set table, pipe output to file
 
 
 
{| style="border-spacing:0;width:6.8472in;"
 
|-
 
! align=center style="background-color:#993366;border-top:1pt solid #000000;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | Visual Cue
 
! align=center style="background-color:#993366;border:1pt solid #000000;padding:0.0382in;" | Narration
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | <div style="color:#000000;">'''Slide Number 1'''</div>
+
| '''Slide Number 1'''
 +
'''Title Slide '''
 +
'''Plotting functions'''
 +
|| Welcome to the tutorial on '''Plotting functions'''
  
<div style="color:#000000;">'''Title Slide '''</div>
 
 
<div style="color:#000000;">'''Plotting functions'''</div>
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Welcome to the tutorial on '''Plotting functions'''
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | <div style="color:#000000;">'''Slide Number 2'''</div>
+
|| '''Slide Number 2'''
 +
'''Learning Objectives'''
 +
|| In this tutorial we will learn,
  
<div style="color:#000000;">'''Learning Objectives'''</div>
+
* Plot & replot commands for 2D plotting
 +
* Plot three functions '''sin x, cos x '''and''' sin x plus cos x'''
 +
* Draw grid and set limits
 +
* Zoom into a graph
  
  
 +
|-
 +
|| '''Slide Number 3'''
 +
'''Learning Objectives'''
 +
||
 +
* Add axis labels and graph title
 +
* Change font style and size
 +
* Add '''Greek''' '''symbols'''
 +
* Set axis tick marks
 +
* Write data points to a table
  
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">In this tutorial we will learn,</div>
 
  
 +
|-
 +
|| '''Slide Number 4'''
 +
'''System and Software Requirement'''
 +
|| To record this tutorial, I am using
 +
* Debian Linux 9.3
 +
* Gedit text editor 3.22.0 and
 +
* gnuplot 5.2.5 installed
  
* <div style="color:#000000;">Plot & replot commands for 2D plotting</div>
+
|-
* <div style="color:#000000;">Plot three functions sin x, cos x and sin x + cos x</div>
+
|| '''Slide Number 5'''
* <div style="color:#000000;">Draw grid and set limits</div>
+
'''Pre-requisites'''
* <div style="color:#000000;">Zoom into a graph</div>
+
|| To follow this tutorial, learners must be familiar with,
 +
* Basic computer and internet skills
 +
* Concept of graphing
 +
and  
 +
* High school level Mathematics skills
  
 +
|-
 +
|| '''Ctrl alt t'''
 +
|| Open a terminal by pressing control alt t keys together
 +
A terminal opens
  
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | <div style="color:#000000;">'''Slide Number 3'''</div>
+
|| '''>gnuplot'''.
 +
|| Enter command '''gnuplot''', to open '''gnuplot'''
  
<div style="color:#000000;">'''Learning Objectives'''</div>
+
|-
 +
|| '''control shift k'''
 +
|| The terminal prompt changes to '''gnuplot''' when program runs
 +
I will clear the screen and bring terminal prompt to top of the screen for clarity.
  
 +
|-
 +
|| >'''plot sin (x)''' and press enter
 +
|| Type, '''plot space sin x'''
 +
Note that angle '''X''' is within braces and press enter
  
 +
|-
 +
||
 +
|| A graphical window with plot of '''x, sin x''' appear on screen
  
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | * <div style="color:#000000;">Add axis labels and graph title</div>
+
|-
* <div style="color:#000000;">Change font style and size</div>
+
|| Hover mouse on graph, axes
* <div style="color:#000000;">Add Greek symbols</div>
+
|| Limit of '''y axis''' is from -1 to plus 1 and '''x axis''' is from -10 to 10
* <div style="color:#000000;">Set axis tick marks</div>
+
* <div style="color:#000000;">Write data points to a table</div>
+
  
 +
|-
 +
|| Click on '''grid''' icon
 +
|| Click on the '''grid''' icon. This draws grid in the '''graph'''.
  
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | <div style="color:#000000;">'''Slide Number 4'''</div>
+
|| Hold '''control''' and zoom in with mouse '''scroll'''
 +
|| Hold down '''control''' key and zoom in around origin, '''0, 0''', with scroll mouse
  
<div style="color:#000000;">'''System and Software Requirement'''</div>
+
|-
 +
||
 +
|| Notice, sin x is zero when '''x''' is zero
  
 +
|-
 +
|| Show zoom in and out
 +
|| Using scroll wheel, zoom in and out in the graph.
  
<div style="color:#000000;"></div>
+
|-
 +
|| Type '''reset''', enter
 +
Type '''replot''', enter
 +
|| To '''reset''', enter command '''reset''' in terminal, followed by '''replot'''
 +
Changes in graph becomes visible only after '''replot''' command
  
<div style="color:#000000;"></div>
+
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">To record this tutorial, I am using</div>
+
||
 +
|| This resets limits of axis as before
  
 +
|-
 +
||
 +
|| Notice the legend in the graph is not clear and runs through the graph
  
<div style="color:#000000;">Debian Linux</div>
+
|-
 +
|| Point mouse on legend
 +
|| Let's increase '''y'''-axis range, so that graph line does not run through legend.
  
<div style="color:#000000;">Gedit 3.22.0 and</div>
+
|-
 +
|| '''>set yrange [-2:2]'''
 +
|| Enter command '''set space yrange space''' '''-2 colon 2''' within '''square''' braces
  
<div style="color:#000000;">gnuplot 5.2.5 installed</div>
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | <div style="color:#000000;">'''Slide Number 5'''</div>
+
|| >'''set xrange [-20:20]'''
 +
|| Change x-range with command '''set space xrange space -20 colon 20 in square braces'''
  
<div style="color:#000000;">'''Samson Microphone'''</div>
+
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">To record audio, I am using '''Samson''' '''USB''' portable microphone was used.</div>
+
|| replot
 +
|| Enter '''replot ''' command to see the updated graph.
  
 +
|-
 +
||
 +
|| Now the changed graph limits are visible.
  
<div style="color:#000000;">The model number '''SAGOMIC'''</div>
+
|-
 +
||
 +
|| Legend has moved upward and does not run through the data line.
  
 +
|-
 +
|| '''>set key top left'''
 +
|| Command '''set space key space top space left''' will move legend to top left side.
  
<div style="color:#000000;">I bought it from '''amazon''' website, for about rupees four thousand</div>
+
|-
 +
|| '''>replot'''
 +
|| Do not forget to '''replot''' to see the result.
  
 +
|-
 +
||
 +
|| Next, let's make the axis fonts larger.
 +
I want to set them at size 14 and in '''Verdana''' style, a bit larger than present
  
<div style="color:#000000;">It may be available in other websites also.</div>
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | <div style="color:#000000;">'''Slide Number 6'''</div>
+
|| '''>set tics font “Verdana, 14”'''  
 +
'''>replot'''
 +
|| Enter command '''set space tics space font''' '''space''' '''Verdana''' '''comma 14''' in double quotes
 +
'''Replot''' to see the result.
  
<div style="color:#000000;">'''Pre-requisites'''</div>
+
|-
 +
||
 +
|| Notice the larger font size in '''Verdana''' style.
  
 +
|-
 +
|| '''set xlabel 'x (angle)' font ‘Verdna, 14’'''
 +
|| Let's set x axis label as '''x angle''' next.
 +
Please follow the commands as seen in the video
 +
Here we are specifying the font style and size in the same command line
  
 +
|-
 +
|| '''set ylabel 'sin (x)' font ‘Verdana, 14’'''
 +
|| To set y-axis label as '''sin x''', type command, as seen in the video
  
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">To follow this tutorial, learner's must be familiar with, </div>
+
|-
 +
||
 +
|| I will set the same font style and size for y axis too.
 +
Changes in graph will become visible only after '''replot''' command.
  
 +
|-
 +
|| '''>replot'''
 +
|| Hence type '''replot''' and enter.
  
<div style="color:#000000;">Basic computer and internet skills</div>
+
|-
 +
|| Type '''set key font ",14"'''
 +
|| '''Set space key space font space comma 14 in double quotes''' command sets font size to 14.
  
 +
|-
 +
|| Type''' help fonts'''
 +
|| To access help documentation on fonts, type '''help space fonts'''
  
<div style="color:#000000;"><span style="background-color:transparent;">Have c</span><span style="background-color:transparent;">oncept of graphing </span></div>
+
|-
 +
|| Point mouse to '''cairo''', '''gd''' and '''postscript'''
 +
|| Help command returns with 3 subtopics '''cairo''', '''gd''' and '''postscript'''
  
<div style="color:#000000;">and </div>
+
|-
 +
|| '''>cairo'''
 +
|| I will type '''cairo''' to see the details and available options
 +
You may pause the video, read & understand the details given in the help section
  
<div style="color:#000000;"><span style="background-color:transparent;">Have h</span><span style="background-color:transparent;">igh school </span><span style="background-color:transparent;">level</span><span style="background-color:transparent;"> math</span><span style="background-color:transparent;">ematics</span><span style="background-color:transparent;"> skill</span><span style="background-color:transparent;">s</span></div>
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | <div style="color:#000000;">'''Slide Number 7'''</div>
+
|| '''ctrl c'''
 +
'''ctrl l'''
 +
|| Similarly you may choose to use help for any command when using '''gnuplot'''.
 +
Press '''control c''' to exit help section
 +
I will clear the screen and bring prompt to top of the screen for clarity.
  
<div style="color:#000000;">'''Pre-requisites'''</div>
+
|-
 +
|| '''>set title 'My first gnuplot''''
 +
|| I will also add a title, reading, '''my first gnuplot'''.
 +
To add title, enter command, '''set space title''' as seen in the '''video'''
  
 +
|-
 +
|| '''>set title font ‘verdana, 18’'''
 +
'''replot'''
 +
|| To set title font, use the command as seen.
 +
Enter '''replot''' command to see the updated graph
  
<div style="color:#000000;"></div>
+
|-
 +
||
 +
|| Note that, x axis has dimensions of angle this plot
 +
Hence we may like to label x-axis, in terms of angle, pi
  
<div style="color:#000000;"></div>
+
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <span style="background-color:transparent;color:#000000;">Please locate this tutorial on our web page, </span><span style="background-color:transparent;color:#000000;">'''spoken hyphen tutorial dot org'''</span><span style="background-color:transparent;color:#000000;"> </span>
+
|| Point at the terminal
 +
Highlight the following command and hover mouse over {/symbol p} and -2*pi
 +
'''set xtics ('-4{/Symbol p}' -4*pi,'-3{/Symbol p}' -3*pi,'-2{/Symbol p}' -2*pi, '-{/Symbol p}' -pi, 0, '{/Symbol p}' pi,'2{/Symbol p}' 2*pi, '3{/Symbol p}' 3*pi, '4{/Symbol p}' 4*pi,)'''
 +
|| To change '''xtics''' to angle, type the following command as seen on screen
 +
Here we are setting Greek pi alphabet and set it's position.
  
 +
|-
 +
|| Point mouse to '''('-2{/Symbol p}'''' and then to '''-2*pi'''
 +
|| This command placed label 2 '''pi '''at position 6.28 at x-axis.
  
<div style="color:#000000;">Pre-requisite '''spoken''' '''tutorials''', if any, will be mentioned in this page </div>
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | <div style="color:#000000;">'''Ctrl alt t'''</div>
+
|| replot
 +
|| '''X'''-tics is labeled, '''Greek''' symbol '''pi''' is placed at value of 3.14
 +
Enter '''replot''' command to see the updated graph
  
 
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Open a terminal by pressing control alt t keys together
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Depending on your operating system, please set terminal
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | <div style="color:#000000;">'''>set term qt'''</div>
+
|| Type '''help set xtics'''
 +
'''ctrl-c'''
 +
|| For more help on formats, enter command, '''help space set space xtics'''.
 +
Pause the video and explore more if you wish to do so.
  
<div style="color:#000000;">'''press enter'''</div>
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">I will type '''set space term space qt'''.</div>
 
 
 
<div style="color:#000000;">Press enter to execute the command.</div>
 
 
 
<div style="color:#000000;">This works for most operating systems</div>
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | '''>gnuplot'''.
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Enter command '''gnuplot''', to open '''gnuplot'''
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | '''Control L'''
+
|| '''ctrl c'''
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">The terminal prompt changes to '''gnuplot''' when program runs</div>
+
|| Press '''control c''' to exit help
 +
It is also possible to add multiple functions on the same graph
  
 
<div style="color:#000000;">I will clear the screen and bring terminal prompt to top of the screen for clarity. </div>
 
 
 
<div style="color:#000000;">Press control l on keypad.</div>
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | >'''plot sin (x)'''<span style="color:#000000;">, press enter</span>
+
||  
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">Type, '''plot space sin x'''</div>
+
|| To plot '''sin''' x and '''cos''' x on same graph, separate the functions by a '''comma'''
  
 
<div style="color:#000000;">Note that angle '''X''' is within braces and press enter</div>
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | A graphical window with plot of x, sin x appear on screen
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | Hover mouse on graph, axes
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Limit of y axis is from -1 to plus 1 and x axis is from -10 to 10
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | Click on '''grid''' icon
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Click on the '''grid''' icon. This draws grid in the '''graph'''.
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | Hold '''control''' and zoom in with mouse '''scroll'''
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Hold down ctrl key and zoom in around origin, 0, 0, with scroll mouse
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Notice, sin x is zero when '''x''' is zero
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | Show zoom in and out
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Using scroll wheel, zoom in and out in the graph.
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | <div style="color:#000000;">Type '''reset''', enter</div>
+
|| '''plot sin (x), cos (x)'''
 +
|| Enter command, '''Plot space sin x comma cos x'''
 +
Make sure, the angle '''x''', is typed within braces
 +
Notice the two functions plotted together
  
<div style="color:#000000;">Type '''replot''', enter</div>
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">To '''reset''', enter command '''reset''' in terminal, followed by '''replot'''</div>
 
 
 
<div style="color:#000000;">Changes in graph becomes visible only after '''replot''' command</div>
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |  
+
||  
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | This resets limits of axis as before
+
|| Next, add '''sin x''' plus '''cos x''' function to the graph
|-
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Notice the legend in the graph is not clear and runs through the graph
+
|-
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | Point mouse on legend
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Let's increase '''y'''-axis range, so that graph line does not run through legend.
+
|-
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | '''>set yrange [-2:2]'''
+
| style="background-color:#ffffff;border:none;padding:0in;color:#000000;" | Enter command '''set space yrange space''' -2 colon 2 within square braces
+
|-
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | >'''set xrange [-20:20]'''
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Change x-range with command '''set space xrange space -20 colon 20 in square braces'''
+
|-
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Enter '''replot '''command to see the updated graph.
+
|-
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Now the changed graph limits are visible.
+
|-
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Legend has moved upward and does not run through the data line.
+
|-
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | '''>set key top left'''
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Command '''set space key space top space left''' will move legend to top left side.
+
|-
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | '''>replot'''
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Do not forget to '''replot''' to see the result.
+
|-
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">Next, let's make the axis fonts larger.</div>
+
 
+
  
<div style="color:#000000;">I want to set them at size 14 and in '''Verdana''' style, a bit larger than present</div>
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | <div style="color:#000000;">'''>set tics font “Verdana, 14”''' </div>
+
|| '''plot sin(x), cos(x), sin(x) + cos(x)'''
 +
|| For this, type '''plot space sin x comma cos x comma sin x plus cos x'''
 +
Notice the three functions plotted together
  
<div style="color:#000000;">'''>replot'''</div>
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">Enter command '''set space tics space font''' '''Verdana''' comma 14 in double quotes</div>
 
 
 
<div style="color:#000000;">'''Replot''' to see the result.</div>
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Notice the larger font size in '''Verdana''' style.
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | <div style="color:#000000;">'''set xlabel 'x (angle)' font “Verdana, 14”'''</div>
+
||  
 +
|| Say, next I want to get '''sin x''' data points''' in a file'''
  
 
<div style="color:#000000;"></div>
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">Let's set x axis label as x angle next. </div>
 
 
 
<div style="color:#000000;">Please follow the commands as<span style="background-color:transparent;"> </span><span style="background-color:transparent;">seen</span> in the video</div>
 
 
 
<div style="color:#000000;">Here we are specifying the font style and size in the same command line</div>
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | '''set ylabel 'sin (x)' font “Verdana, 14”'''
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | To set y-axis label as '''sin x''', type command, as seen in the video
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | To specify the style and size of '''axis''' label, add font details in the setting.
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | I will set the same font style and size for y axis too.
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Changes in graph will become visible only after '''replot''' command.
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | '''>replot'''
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Hence type '''replot''' and enter.
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | Type {{anchor|DdeLink50272102207422}} '''set key font ",14"'''
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | '''Set space key space font space ,14 in double quotes''' command sets font size to 14.
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | Type''' help fonts'''
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | To access help documentation on fonts, type '''help space fonts'''
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | Point mouse to '''cairo''', '''gd''' and '''postscript'''
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Help command returns with 3 subtopics '''cairo''', '''gd''' and '''postscript'''
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | '''>cairo'''
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | I will type '''cairo''' to see the details and available options
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | You may pause the video, read & understand the details given in the help section
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | <div style="color:#000000;">'''Ctrl c'''</div>
+
|| '''set table'''
 +
|| To get an '''ascii''' column format output, '''set table''' command can be used
 +
First enter command '''set space table'''
  
<div style="color:#000000;">'''ctrl l'''</div>
 
 
 
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">Similarly you may choose to use help for any command when using '''gnuplot'''.</div>
 
 
 
<div style="color:#000000;">Press '''control c''' to exit help section</div>
 
 
 
<div style="color:#000000;">Press '''control l''' on keypad</div>
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | '''>set title 'My first gnuplot''''
+
|| '''plot sin(x)'''
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">I will also add a title, reading, '''my first gnuplot'''. </div>
+
|| Type, '''plot space sinx'''
 +
An '''x y''' column data for '''sin x''' is generated on the screen
  
 
<div style="color:#000000;">To add title, enter command, '''set space title''' , as seen in the '''video'''</div>
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | '''>set title font "verdana, 18"'''
+
|| x y column data is generated on the screen
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | To set title font, use the command as seen.
+
|| First column is '''x''' data and second column is '''y''' data points of '''x sinx''' graph
|-
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">Note that, x axis has dimensions of angle this plot</div>
+
 
+
  
<div style="color:#000000;">Hence we may like to label x-axis, in terms of angle, pi</div>
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | <div style="color:#000000;">Point at the terminal</div>
+
|| Clear screen , ctrl shift k
 +
|| We can pipe or 'direct' the output to a text file.
 +
I will clear the screen and bring prompt to top of the screen for clarity.
  
 
<div style="color:#000000;">Highlight the following command and hover mouse over {/symbol p} and -2*pi</div>
 
 
 
<div style="color:#000000;">'''set xtics ('-4{/Symbol p}' -4*pi,'-3{/Symbol p}' -3*pi,'-2{/Symbol p}' -2*pi, '-{/Symbol p}' -pi, 0, '{/Symbol p}' pi,'2{/Symbol p}' 2*pi, '3{/Symbol p}' 3*pi, '4{/Symbol p}' 4*pi,)'''</div>
 
 
 
<div style="color:#000000;">{{anchor|DdeLink16131552048718}} '''set xtics ('-2{/Symbol p}' -2*pi, '-{/Symbol p}' -pi, 0, '{/Symbol p}' pi,'2{/Symbol p}' 2*pi)'''</div>
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">To change '''xtics''' to angle, type the following command as seen on screen</div>
 
 
 
<div style="color:#000000;">Here we are setting Greek pi alphabet and set it's position.</div>
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | Point mouse to '''('-2{/Symbol p}'''' and then to '''-2*pi'''
+
|| >'''set table "table-sinx.txt"'''  
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | This command placed label 2 pi''' '''at position 6.28 at x-axis.
+
|| For this, type, '''set space table space in double quotes table hyphen sinx dot txt'''
|-
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | '''X'''-tics is labeled, '''Greek''' symbol pi is placed at value of 3.14
+
|-
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | Type '''help set xtics'''
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">For more help on formats, enter command, '''help space set space xtics'''.</div>
+
 
+
  
<div style="color:#000000;">Pause the video and explore more if you wish to do so.</div>
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | '''Ctrl c'''
+
|| '''plot sin(x)'''
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">Press '''control c''' to exit help</div>
+
|| Type '''plot space sin x'''
 +
Here, the output is directed to file name '''table hyphen sin x dot txt'''
  
 
<div style="color:#000000;">It is also possible to add multiple functions on the same graph</div>
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | To plot '''sin''' x and '''cos''' x on same graph, separate the functions by a comma
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | '''plot sin (x), cos (x)'''
+
||  
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">Enter command, '''Plot space sin x comma cos x''' </div>
+
|| The file is stored in the directory from where we opened '''gnuplot''' in terminal.
 +
We can remove tabular outputs with unset table command
  
 
<div style="color:#000000;">Make sure, the angle '''x''', is typed within braces</div>
 
 
 
<div style="color:#000000;">Notice the two functions plotted together</div>
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Next, add '''sin x''' plus '''cos x''' function to the graph
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | '''plot sin(x), cos(x), sin(x) + cos(x)'''
+
|| >'''unset table'''
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">For this, type '''plot space sin(x) comma cos(x) comma sin(x) plus cos(x)''' </div>
+
|| Enter command '''unset space table''' to unset '''table''' mode
  
 
<div style="color:#000000;">Notice the three functions plotted together</div>
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Say, next I want to get '''sin(x)''' data points''' in a file'''
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | To get an ascii column format output, '''set table''' command can be used
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | '''plot sin(x)'''
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | First enter command '''set space table'''
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | '''plot sin(x)'''
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Type, '''plot space sinx'''
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | An x-y column data for sin(x) is generated on the screen
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | First column is x data and second column is y data points of '''x sinx''' graph
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | We can pipe or 'direct' the output to a text file.
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | >'''set table "table-sinx.txt"'''  
+
|| '''Slide Number 6'''
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">For this, type, '''set space table space in double quotes table hyphen sinx dot txt'''</div>
+
'''Summary'''
 +
|| To summarize, in this tutorial, we
 +
Learned to
 +
* Plot 2D graphs of simple functions
 +
* Added grid and set limits
 +
* Zoomed and viewed graph
 +
* Added axis labels, graph title
 +
* Change font style, size
 +
and
 +
* Wrote data points to table
  
 
<div style="color:#000000;">Here, the output is directed to file name '''table hyphen sin x dot txt'''</div>
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | The file is stored in the directory from where we opened '''gnuplot''' in terminal.
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | We can remove tabular outputs with unset table command
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" | >'''unset table'''
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Enter command '''unset space table''' to unset '''table''' mode
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | <div style="color:#000000;">'''Slide Number 8'''</div>
+
|| '''Slide Number 7'''
 +
'''Assignment'''
 +
|| For assignment, plot the following functions,
 +
* tan x
 +
* Legendre polynomial
 +
* a parabola
 +
and
 +
* Open parabola in four different quadrants
  
<div style="color:#000000;">'''Summary'''</div>
 
 
 
<div style="color:#000000;"></div>
 
 
<div style="color:#000000;"></div>
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | To summarize, in this tutorial, we
 
 
<div style="color:#000000;">Learned to </div>
 
 
 
<div style="color:#000000;">Plot 2D graphs of simple functions</div>
 
 
<div style="color:#000000;">Added grid and set limits</div>
 
 
<div style="color:#000000;">Zoomed and viewed graph</div>
 
 
<div style="color:#000000;">Added axis labels, graph title </div>
 
 
<div style="color:#000000;"><span style="background-color:transparent;">Change</span><span style="background-color:transparent;">d</span><span style="background-color:transparent;"> font style </span><span style="background-color:transparent;">and</span><span style="background-color:transparent;"> size</span></div>
 
 
<div style="color:#000000;">and</div>
 
 
<div style="color:#000000;">Wrote data points to table</div>
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | <div style="color:#000000;">'''Slide Number 9'''</div>
+
|| '''Slide Number 8'''
 +
'''Spoken Tutorial Project'''
 +
||This video summarises the Spoken Tutorial Project
 +
Please download and watch it.
  
<div style="color:#000000;">'''Assignment'''</div>
 
 
 
<div style="color:#000000;"></div>
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">For assignment, plot the following functions,</div>
 
 
 
<div style="color:#000000;">tan x </div>
 
 
<div style="color:#000000;">Legendre polynomial</div>
 
 
<div style="color:#000000;">a parabola </div>
 
 
<div style="color:#000000;">and </div>
 
 
<div style="color:#000000;">Open parabola in four different quadrants</div>
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | <div style="color:#000000;">'''Slide Number 10'''</div>
+
|| '''Slide Number 9'''
 +
'''Spoken Tutorial workshops'''
 +
|| We conduct workshops and give certificates.
 +
Please write to us.
  
<div style="color:#000000;">'''Spoken Tutorial Project'''</div>
 
 
 
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <span style="color:#000000;">This video summarises the</span><span style="color:#000000;"> Spoken Tutorial Project </span>
 
 
 
<div style="color:#000000;">If you do not have good bandwidth, you may download and watch it.</div>
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | <div style="color:#000000;">'''Slide Number 11'''</div>
+
|| '''Slide Number 10'''
 +
'''Forum for specific questions:'''
 +
|| Post your timed queries in the forum.
  
<div style="color:#000000;">'''Spoken Tutorial workshops'''</div>
 
 
 
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <span style="color:#000000;">We</span><span style="color:#000000;"> conduct workshops using spoken tutorials and give certificates. </span>
 
 
 
<span style="color:#000000;">P</span><span style="color:#000000;">lease write to us.</span>
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | <div style="color:#000000;">'''Slide Number 12'''</div>
+
|| '''Slide Number 11'''
 +
'''Acknowledgement’’’
 +
|| Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India.
  
<div style="color:#000000;">'''Forum for specific questions:'''</div>
 
 
 
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | Post your timed queries in the forum.
 
 
|-
 
|-
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;" | <div style="color:#000000;">'''Slide Number 13'''</div>
+
||  
 +
|| This is Rani from IIT, Bombay. Thank you for joining.
  
<span style="color:#000000;">'''Acknowledgemen'''</span><span style="color:#000000;">t</span>
 
 
 
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India.</div>
 
 
 
 
|-
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.0382in;color:#000000;" |
 
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.0382in;color:#000000;" | This is Rani from IIT, Bombay. Thank you for joining.
 
 
|-
 
|-
 
|}
 
|}
<div style="color:#000000;margin-left:0in;margin-right:0in;"></div>
 

Revision as of 11:34, 21 February 2019

Visual Cue Narration
Slide Number 1

Title Slide Plotting functions

Welcome to the tutorial on Plotting functions
Slide Number 2

Learning Objectives

In this tutorial we will learn,
  • Plot & replot commands for 2D plotting
  • Plot three functions sin x, cos x and sin x plus cos x
  • Draw grid and set limits
  • Zoom into a graph


Slide Number 3

Learning Objectives

  • Add axis labels and graph title
  • Change font style and size
  • Add Greek symbols
  • Set axis tick marks
  • Write data points to a table


Slide Number 4

System and Software Requirement

To record this tutorial, I am using
  • Debian Linux 9.3
  • Gedit text editor 3.22.0 and
  • gnuplot 5.2.5 installed
Slide Number 5

Pre-requisites

To follow this tutorial, learners must be familiar with,
  • Basic computer and internet skills
  • Concept of graphing

and

  • High school level Mathematics skills
Ctrl alt t Open a terminal by pressing control alt t keys together

A terminal opens

>gnuplot. Enter command gnuplot, to open gnuplot
control shift k The terminal prompt changes to gnuplot when program runs

I will clear the screen and bring terminal prompt to top of the screen for clarity.

>plot sin (x) and press enter Type, plot space sin x

Note that angle X is within braces and press enter

A graphical window with plot of x, sin x appear on screen
Hover mouse on graph, axes Limit of y axis is from -1 to plus 1 and x axis is from -10 to 10
Click on grid icon Click on the grid icon. This draws grid in the graph.
Hold control and zoom in with mouse scroll Hold down control key and zoom in around origin, 0, 0, with scroll mouse
Notice, sin x is zero when x is zero
Show zoom in and out Using scroll wheel, zoom in and out in the graph.
Type reset, enter

Type replot, enter

To reset, enter command reset in terminal, followed by replot

Changes in graph becomes visible only after replot command

This resets limits of axis as before
Notice the legend in the graph is not clear and runs through the graph
Point mouse on legend Let's increase y-axis range, so that graph line does not run through legend.
>set yrange [-2:2] Enter command set space yrange space -2 colon 2 within square braces
>set xrange [-20:20] Change x-range with command set space xrange space -20 colon 20 in square braces
replot Enter replot command to see the updated graph.
Now the changed graph limits are visible.
Legend has moved upward and does not run through the data line.
>set key top left Command set space key space top space left will move legend to top left side.
>replot Do not forget to replot to see the result.
Next, let's make the axis fonts larger.

I want to set them at size 14 and in Verdana style, a bit larger than present

>set tics font “Verdana, 14”

>replot

Enter command set space tics space font space Verdana comma 14 in double quotes

Replot to see the result.

Notice the larger font size in Verdana style.
set xlabel 'x (angle)' font ‘Verdna, 14’ Let's set x axis label as x angle next.

Please follow the commands as seen in the video Here we are specifying the font style and size in the same command line

set ylabel 'sin (x)' font ‘Verdana, 14’ To set y-axis label as sin x, type command, as seen in the video
I will set the same font style and size for y axis too.

Changes in graph will become visible only after replot command.

>replot Hence type replot and enter.
Type set key font ",14" Set space key space font space comma 14 in double quotes command sets font size to 14.
Type help fonts To access help documentation on fonts, type help space fonts
Point mouse to cairo, gd and postscript Help command returns with 3 subtopics cairo, gd and postscript
>cairo I will type cairo to see the details and available options

You may pause the video, read & understand the details given in the help section

ctrl c

ctrl l

Similarly you may choose to use help for any command when using gnuplot.

Press control c to exit help section I will clear the screen and bring prompt to top of the screen for clarity.

>set title 'My first gnuplot' I will also add a title, reading, my first gnuplot.

To add title, enter command, set space title as seen in the video

>set title font ‘verdana, 18’

replot

To set title font, use the command as seen.

Enter replot command to see the updated graph

Note that, x axis has dimensions of angle this plot

Hence we may like to label x-axis, in terms of angle, pi

Point at the terminal

Highlight the following command and hover mouse over {/symbol p} and -2*pi set xtics ('-4{/Symbol p}' -4*pi,'-3{/Symbol p}' -3*pi,'-2{/Symbol p}' -2*pi, '-{/Symbol p}' -pi, 0, '{/Symbol p}' pi,'2{/Symbol p}' 2*pi, '3{/Symbol p}' 3*pi, '4{/Symbol p}' 4*pi,)

To change xtics to angle, type the following command as seen on screen

Here we are setting Greek pi alphabet and set it's position.

Point mouse to ('-2{/Symbol p}' and then to -2*pi This command placed label 2 pi at position 6.28 at x-axis.
replot X-tics is labeled, Greek symbol pi is placed at value of 3.14

Enter replot command to see the updated graph

Type help set xtics

ctrl-c

For more help on formats, enter command, help space set space xtics.

Pause the video and explore more if you wish to do so.

ctrl c Press control c to exit help

It is also possible to add multiple functions on the same graph

To plot sin x and cos x on same graph, separate the functions by a comma
plot sin (x), cos (x) Enter command, Plot space sin x comma cos x

Make sure, the angle x, is typed within braces Notice the two functions plotted together

Next, add sin x plus cos x function to the graph
plot sin(x), cos(x), sin(x) + cos(x) For this, type plot space sin x comma cos x comma sin x plus cos x

Notice the three functions plotted together

Say, next I want to get sin x data points in a file
set table To get an ascii column format output, set table command can be used

First enter command set space table

plot sin(x) Type, plot space sinx
An x y column data for sin x is generated on the screen 
x y column data is generated on the screen First column is x data and second column is y data points of x sinx graph
Clear screen , ctrl shift k We can pipe or 'direct' the output to a text file.

I will clear the screen and bring prompt to top of the screen for clarity.

>set table "table-sinx.txt" For this, type, set space table space in double quotes table hyphen sinx dot txt
plot sin(x) Type plot space sin x

Here, the output is directed to file name table hyphen sin x dot txt

The file is stored in the directory from where we opened gnuplot in terminal.

We can remove tabular outputs with unset table command

>unset table Enter command unset space table to unset table mode
Slide Number 6

Summary

To summarize, in this tutorial, we

Learned to

  • Plot 2D graphs of simple functions
  • Added grid and set limits
  • Zoomed and viewed graph
  • Added axis labels, graph title
  • Change font style, size

and

  • Wrote data points to table
Slide Number 7

Assignment

For assignment, plot the following functions,
  • tan x
  • Legendre polynomial
  • a parabola

and

  • Open parabola in four different quadrants
Slide Number 8

Spoken Tutorial Project

This video summarises the Spoken Tutorial Project

Please download and watch it.

Slide Number 9

Spoken Tutorial workshops

We conduct workshops and give certificates.

Please write to us.

Slide Number 10

Forum for specific questions:

Post your timed queries in the forum.
Slide Number 11

Acknowledgement’’’

Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India.
This is Rani from IIT, Bombay. Thank you for joining.

Contributors and Content Editors

Madhurig, Ranipv076