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...")
 
 
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''Title of script''': '''Plotting functions'''
+
{|border=1
 +
||'''Visual Cue'''
 +
||'''Narration'''
  
'''Author: '''Rani Parvathy
+
|-
 +
||'''Slide Number 1'''
 +
'''Title Slide '''
 +
'''Plotting functions'''
 +
|| Welcome to the tutorial on '''Plotting functions in gnuplot'''.
  
'''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
+
|-
 +
|| '''Slide Number 2'''
 +
'''Learning Objectives'''
 +
|| In this tutorial we will learn,
  
 +
* '''Plot''' and '''replot commands''' for '''2D''' plotting
 +
* Plot three '''functions: '''sin(x)''', '''cos(x)''' and '''sin(x) plus cos(x)'''
 +
* Draw grid and set limits
 +
* Zoom in and zoom out of a plot
  
{| 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
+
|| '''Slide Number 3'''
! align=center style="background-color:#993366;border:1pt solid #000000;padding:0.0382in;" | Narration
+
'''Learning Objectives'''
 +
||
 +
* Add axis labels and graph title
 +
* Change font '''style''' and size
 +
* Add '''Greek symbols'''
 +
* Set axis '''tick marks ''' and
 +
* Save the data points to 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;" | <div style="color:#000000;">'''Slide Number 1'''</div>
+
|| '''Slide Number 4'''
 +
'''System and Software Requirement'''
 +
|| To record this tutorial, I am using
  
<div style="color:#000000;">'''Title Slide '''</div>
+
* '''Debian Linux''' 9.3
 +
* '''gnuplot''' 5.2.6 and
 +
* '''Gedit text editor''' 3.22.0
  
<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 5'''
 +
'''Pre-requisites'''
 +
|| To follow this tutorial,
  
<div style="color:#000000;">'''Learning Objectives'''</div>
+
* Learner must be familiar with high school level Mathematics
 +
* For prerequisite gnuplot tutorials, please visit this site
  
 +
|-
 +
|| Press '''Ctrl + Alt + T''' .
 +
|| Open a '''terminal''' by pressing '''Ctrl, Alt''' and '''T''' keys simultaneously.
  
 +
|-
 +
|| Type cd Desktop and press '''Enter'''.
 +
|| A terminal opens.
 +
Change directory to '''Desktop''' as seen.
  
| 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>
+
|-
 +
|| Type '''gnuplot''' and press '''Enter'''.
 +
|| In the '''terminal''', type '''gnuplot''' and press '''Enter'''.
  
 +
|-
 +
|| Hover mouse near gnuplot prompt.
 +
|| The '''prompt''' changes to '''gnuplot prompt.'''
  
* <div style="color:#000000;">Plot & replot commands for 2D plotting</div>
+
To execute a '''command''' in the '''terminal''', press '''Enter''' after typing it.
* <div style="color:#000000;">Plot three functions sin x, cos x and sin x + cos x</div>
+
* <div style="color:#000000;">Draw grid and set limits</div>
+
* <div style="color:#000000;">Zoom into a graph</div>
+
  
 +
I will not mention this separately.
  
 
|-
 
|-
| 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>
+
|| Press''' Ctrl+Shift+K'''.
 +
|| I will clear the '''terminal'''.
  
<div style="color:#000000;">'''Learning Objectives'''</div>
+
|-
 +
|| Type '''plot sin(x)''' and Press '''Enter'''.
 +
|| Now type '''plot space sin(x)'''.
  
 +
Note that angle '''x''' is within parentheses.
  
 +
|-
 +
|| Point to graphical window.
 +
|| A graphical window with plot of '''sin(x)''' versus '''x''' appears 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;" | * <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>
+
|| The limit of '''Y''' axis is from minus 1 to plus 1.
* <div style="color:#000000;">Set axis tick marks</div>
+
And '''X''' axis is from -10 to 10.
* <div style="color:#000000;">Write data points to a table</div>
+
  
 +
|-
 +
|| Type '''set grid''' and press '''Enter'''.
 +
|| Come back to the '''terminal''' and type the command '''set space grid'''.
  
 
|-
 
|-
| 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>
+
|| Type '''replot''' and press '''Enter'''
 +
|| Then type''' replot''' to see the grid in the graph.
  
<div style="color:#000000;">'''System and Software Requirement'''</div>
+
|-
 +
|| Hold Ctrl and zoom in with mouse scroll.
 +
|| Hold down the control key and move the mouse scroll wheel to zoom in and zoom out.
  
 +
|-
 +
|| Point to '''sin x '''and '''x'''.
 +
|| Observe that '''sin x''' is zero when '''x''' is zero.
  
<div style="color:#000000;"></div>
+
|-
 +
|| Show zoom in and out.
 +
|| Let us reset the limits of the axes as before.
  
<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>
+
|| Type '''reset''' and  press '''Enter'''.
 +
|| To reset, type the command reset in the '''terminal''', followed by '''replot'''.
  
 +
|-
 +
|| Type '''replot''' and press '''Enter'''.
 +
|| Changes in the graph become visible only after executing the '''replot''' command.
  
<div style="color:#000000;">Debian Linux</div>
+
|-
 +
|| Point to the '''legend'''.
 +
|| Notice that the '''legend''' is on the top right side in the graph.
  
<div style="color:#000000;">Gedit 3.22.0 and</div>
+
It is not clear and intersects the graph.
  
<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>
+
|| Point mouse on the '''legend'''.
 +
|| Let's increase '''y axis range''', so that the graph line does not run through the '''legend'''.
  
<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>
+
|| Type '''set yrange [-2:2]''' and press '''Enter'''.
 +
|| Type '''set space yrange space -2 colon 2''' within square brackets.
  
 +
|-
 +
|| Type '''set xrange [-20:20]''' and
 +
Press '''Enter'''.
 +
|| I will also change '''x''' axis range.
  
<div style="color:#000000;">The model number '''SAGOMIC'''</div>
+
Enter command, '''set space xrange space -20 colon 20''' within square brackets.
  
 +
|-
 +
|| Type '''replot''' and
 +
Press '''Enter'''
 +
|| Type '''replot''' to see the updated graph.
  
<div style="color:#000000;">I bought it from '''amazon''' website, for about rupees four thousand</div>
+
|-
 +
|| Cursor on the graph.
 +
|| Now the changed graph limits are visible.
  
 +
|-
 +
|| Point to the '''legend'''.
 +
|| The '''legend''' has moved up and does not intersect the data line anymore.
  
<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>
+
|| Type '''set key top left''' and press '''Enter'''
 +
|| Type '''set space key space top space left''' to move the '''legend''' to the top left side.
  
<div style="color:#000000;">'''Pre-requisites'''</div>
+
|-
 +
|| '''Type replot''' and press '''Enter'''.
 +
|| Do not forget to '''replot''' to see the result.
  
 +
|-
 +
|| Hover mouse next to axis font.
 +
|| Next, let's make the axes fonts larger.
  
 +
I want to set them at size 14 and in '''Verdana style'''.
  
| 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>
+
|-
 +
|| Type '''set tics font “Verdana, 14”''' and press '''Enter'''.
 +
|| Type this '''command''' as shown here, to change the font size and '''style'''.
 +
'''Replot''' to see the result.
  
 +
|-
 +
|| Hover mouse next to axis font.
 +
|| Notice the larger font size in '''Verdana style'''.
  
<div style="color:#000000;">Basic computer and internet skills</div>
+
|-
 +
|| Type '''set xlabel 'x (angle)' font “Verdana, 14”'''
 +
Press '''Enter'''
 +
|| Let's set '''x axis label''' as '''x angle'''.
  
 +
Type the '''command''' as shown here.
  
<div style="color:#000000;"><span style="background-color:transparent;">Have c</span><span style="background-color:transparent;">oncept of graphing </span></div>
+
Here we are specifying the '''label''', '''font style''' and size in a single command.
  
<div style="color:#000000;">and </div>
+
|-
 +
|| Type '''set ylabel 'sin (x)' font “Verdana, 14”''' and press '''Enter'''.
 +
|| To set '''y axis label''' as '''sin x''', type the '''command''', as shown here.
  
<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>
+
|| Cursor on the terminal.
 +
|| We are using the same font size and style for y axis too.
  
<div style="color:#000000;">'''Pre-requisites'''</div>
+
|-
 +
|| Type '''replot''' and press '''Enter'''
 +
|| Type '''replot''' and press '''Enter'''.
  
 +
|-
 +
|| Cursor on the graph.
 +
|| Now, let’s see how to change the font in the '''legend'''.
  
<div style="color:#000000;"></div>
+
|-
 +
|| Type '''set key font ",16"'''  and
 +
Press '''Enter'''
 +
|| Type
 +
'''set space key space font space '''within double quotes '''comma 16 '''.
  
<div style="color:#000000;"></div>
+
This '''command''' sets the '''legend''' font size to 16.
| 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>
+
  
 +
|-
 +
|| Press '''Ctrl+Alt+K'''.
 +
|| I will clear the terminal.
  
<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>
+
|| Type''' help fonts''' and press '''Enter'''
 +
|| 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: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;" |  
+
|| 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;" | Depending on your operating system, please set terminal
+
|| 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;" | <div style="color:#000000;">'''>set term qt'''</div>
+
|| Type '''cairo''' and press '''Enter'''
 +
|| I will type '''cairo''' to see the details and available options.
  
<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>
+
|| Cursor on the terminal.
 +
|| Similarly you may choose to use '''help''' for any '''command''' when using '''gnuplot'''.
  
 +
|-
 +
|| Mouse in '''Help section'''.
 +
|| You may pause the video and read the details given in the '''help''' section.
  
<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'''
+
|| Press '''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>
+
|| Once done, press '''Control '''and '''C''' keys to exit the '''help section'''.
  
 
<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>
+
|| '''Ctrl+L in Ubuntu''' and '''Ctrl+Shift+K in Debian'''.
| 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>
+
|| I will clear the screen.
 
+
I wish to add a title to my graph.
  
<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;" |  
+
|| Type '''set title 'My first gnuplot'''' and press '''Enter'''.
| 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
+
|| To add a title, type '''set title''' command, as shown here.  
|-
+
| 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>
+
  
<div style="color:#000000;">Type '''replot''', enter</div>
+
Followed by the title of the graph in single quotes.
| 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
 
|-
 
| 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;" |
+
|| Type '''set title font "verdana, 18"''' and press '''Enter'''.
| 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>
+
|| To set the title font, type the command as shown here.
  
 
<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>
+
|| '''Point to x axis'''.
 +
|| In the '''sinx versus x''' plot, dimensions of '''x axis''' is angle.
 +
Hence we may want to label '''X''' axis in terms of angle, '''π'''.
  
<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>
+
|| In the terminal, type,
 +
'''set xtics ('-4{/Symbol p}' -4*pi,'-3{/Symbol p}' -3*pi,'-2{/Symbol p}' -2*pi,'''
  
 +
''''-{/Symbol p}' -pi, 0, '{/Symbol p}' pi,'''
  
<div style="color:#000000;"></div>
+
''' '2{/Symbol p}' 2*pi, '3{/Symbol p}' 3*pi, '4{/Symbol p}' 4*pi,)''' and
| 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>
+
press '''Enter'''.
 +
|| To change '''X ticks''' to angle, type the following '''command''' as shown on the screen.
  
 +
Here we are using the '''Greek''' alphabet '''pi''' and setting its position.
  
<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>
+
|-
 +
|| Point mouse to '''('2{/Symbol p}'''' and then to '''2*pi'''.
 +
|| This '''command''' places, '''Greek symbol pi''', at the value of 3.14.
  
 +
Label 2'''π''' is at position 6.28 on the '''X''' axis.
  
<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”'''
+
|| Point to '''''' and ''''''.
| 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
+
|| Multiples of pi are placed at their respective positions.
 
|-
 
|-
| 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''' and press '''Enter'''.
| 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.
+
|| For more help on the formats of '''x tics''', type the command '''help space set space xtics'''.
 +
 
 
|-
 
|-
| 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;" |  
+
|| Press '''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;color:#000000;" | I will set the same font style and size for y axis too.
+
|| Press '''Ctrl''' and''' C''' keys to exit 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;color:#000000;" |  
+
|| Press '''Ctrl+Shift+K in Debian'''.
| 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.  
+
|| I will clear the 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;" | '''>replot'''
+
|| Cursor on the terminal.
| 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.  
+
|| It is also possible to add multiple '''functions''' on the same 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;" | Type {{anchor|DdeLink50272102207422}} '''set key font ",14"'''
+
|| Type '''plot sin(x), cos (x) ''' and press '''Enter'''.
| 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.  
+
|| To plot '''sin x '''and '''cos x '''on the 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;" | 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>
+
  
<div style="color:#000000;">'''ctrl l'''</div>
+
Type '''plot space sin x comma cos x'''.
  
 +
Make sure that the angle''' x''', is within parentheses.
  
 +
|-
 +
|| Point to the graph window.
 +
|| Notice that the two '''functions''' are plotted together now.
  
| 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>
+
|-
 +
||  Cursor on the terminal.
 +
|| Next, we will add '''sin (x) plus cos (x) function''' to the same graph.
  
 +
|-
 +
|| Type '''plot sin(x), cos(x), sin(x) + cos(x) ''' and press '''Enter'''.
 +
|| For this, type '''plot space sin(x) comma cos(x) comma sin(x) plus cos(x)''' .
  
<div style="color:#000000;">Press '''control c''' to exit help section</div>
+
|-
 +
|| Point to the graph window.
 +
|| Notice that all 3 '''functions''' are plotted together on the same graph window.
  
 +
Next, let’s learn how to get '''sin(x) data points''' into a file.
  
<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''''
+
||  Cursor on the terminal.
| 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>
+
|| To get an '''ASCII column format''' output, '''set table command''' can be used.
  
 +
|-
 +
|| Type '''set space table''' and press '''Enter'''.
 +
|| First type '''set space table'''.
  
<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"'''
+
|| '''Enter command plot sin(x) '''and press '''Enter'''.
| 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.
+
|| Then type '''plot space sin(x)'''.
 +
 
 
|-
 
|-
| 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 to 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;" | <div style="color:#000000;">Note that, x axis has dimensions of angle this plot</div>
+
|| An '''x y column data''' for '''sin(x)''' is generated on the screen.
  
 
<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>
+
|| Highlight first column.
 +
Highlight second column.
 +
|| The first column is '''x data''' and the second column is '''y data'''.
  
 +
They are the '''points''' of '''sin''' '''x '''versus '''x''' graph.
  
<div style="color:#000000;">Highlight the following command and hover mouse over {/symbol p} and -2*pi</div>
+
|-
 +
|| Press '''Ctrl+Alt+K'''
 +
|| I will clear the terminal.
  
 +
We can save the output as a text file.
  
<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>
+
|-
 +
|| Type '''set table "table-sinx.txt"''' and press '''Enter'''.
 +
|| For this, type '''set space table space '''within double quotes''' sinx dot txt'''.
  
 +
Here '''sinx dot txt''' is the output filename.
  
<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>
+
||Type '''plot sin(x)''' and press '''Enter'''.
 +
|| Then, type '''plot space sin(x)'''.
 +
The output is saved to the file '''sin x dot txt'''.
  
 +
The data is not seen on the screen.
  
<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'''
+
|| Show screenshot of '''Desktop''' showing the file '''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.
+
|| The file is stored in the '''directory''' from where we opened '''gnuplot''' in the '''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;" | '''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'''
+
|| Type '''unset table''' and press '''Enter'''.
| 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 '''unset space table''' to exit the tabular output mode.
  
 
<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;" |  
+
|| Enter the command '''quit'''.
| 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
+
|| Then type '''quit''' or '''q''' to quit '''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;" | '''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>
+
 
+
 
+
<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;" |  
+
|| '''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;color:#000000;" | Next, add '''sin x''' plus '''cos x''' function to the graph
+
'''Summary'''
|-
+
|| Let’s summarize.
| 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)'''
+
In this tutorial,  
| 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>
+
  
 +
* we plotted '''2D''' graphs of '''functions'''.
 +
We also
 +
* Added grid and set limits
 +
* Zoomed in and zoomed out of a plot
 +
* Added axis labels and graph title
 +
* Changed font style and size
 +
and
 +
* Saved the '''data points''' to a file
  
<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;" |  
+
|| '''Slide Number 7'''
| 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'''
+
'''Assignment'''
|-
+
|| As an assignment, plot the following '''functions''':
| 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;" |
+
* '''tan 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;" | To get an ascii column format output, '''set table''' command can be used
+
* '''x squared'''  
|-
+
and
| 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)'''
+
* '''x minus three squared '''
| 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"'''
+
| 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>
+
  
 
<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>
+
|| Show '''Completed assignment'''.
 +
|| Your completed assignment should look like this.
  
<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'''
<div style="color:#000000;">'''Assignment'''</div>
+
|| This video summarises the Spoken Tutorial Project.
 
+
Please download and watch it.
 
+
<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 using spoken tutorials 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'''
  
<div style="color:#000000;">'''Spoken Tutorial workshops'''</div>
+
'''Forum for specific questions:'''
 +
|| 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: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>
 

Latest revision as of 16:56, 18 October 2019

Visual Cue Narration
Slide Number 1

Title Slide Plotting functions

Welcome to the tutorial on Plotting functions in gnuplot.
Slide Number 2

Learning Objectives

In this tutorial we will learn,
  • Plot and replot commands for 2D plotting
  • Plot three functions: sin(x), cos(x) and sin(x) plus cos(x)
  • Draw grid and set limits
  • Zoom in and zoom out of a plot
Slide Number 3

Learning Objectives

  • Add axis labels and graph title
  • Change font style and size
  • Add Greek symbols
  • Set axis tick marks and
  • Save the data points to a file
Slide Number 4

System and Software Requirement

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

Pre-requisites

To follow this tutorial,
  • Learner must be familiar with high school level Mathematics
  • For prerequisite gnuplot tutorials, please visit this site
Press Ctrl + Alt + T . Open a terminal by pressing Ctrl, Alt and T keys simultaneously.
Type cd Desktop and press Enter. A terminal opens.

Change directory to Desktop as seen.

Type gnuplot and press Enter. In the terminal, type gnuplot and press Enter.
Hover mouse near gnuplot prompt. The prompt changes to gnuplot prompt.

To execute a command in the terminal, press Enter after typing it.

I will not mention this separately.

Press Ctrl+Shift+K. I will clear the terminal.
Type plot sin(x) and Press Enter. Now type plot space sin(x).

Note that angle x is within parentheses.

Point to graphical window. A graphical window with plot of sin(x) versus x appears on the screen.
Hover mouse on graph, axes. The limit of Y axis is from minus 1 to plus 1.

And X axis is from -10 to 10.

Type set grid and press Enter. Come back to the terminal and type the command set space grid.
Type replot and press Enter Then type replot to see the grid in the graph.
Hold Ctrl and zoom in with mouse scroll. Hold down the control key and move the mouse scroll wheel to zoom in and zoom out.
Point to sin x and x. Observe that sin x is zero when x is zero.
Show zoom in and out. Let us reset the limits of the axes as before.
Type reset and press Enter. To reset, type the command reset in the terminal, followed by replot.
Type replot and press Enter. Changes in the graph become visible only after executing the replot command.
Point to the legend. Notice that the legend is on the top right side in the graph.

It is not clear and intersects the graph.

Point mouse on the legend. Let's increase y axis range, so that the graph line does not run through the legend.
Type set yrange [-2:2] and press Enter. Type set space yrange space -2 colon 2 within square brackets.
Type set xrange [-20:20] and

Press Enter.

I will also change x axis range.

Enter command, set space xrange space -20 colon 20 within square brackets.

Type replot and

Press Enter

Type replot to see the updated graph.
Cursor on the graph. Now the changed graph limits are visible.
Point to the legend. The legend has moved up and does not intersect the data line anymore.
Type set key top left and press Enter Type set space key space top space left to move the legend to the top left side.
Type replot and press Enter. Do not forget to replot to see the result.
Hover mouse next to axis font. Next, let's make the axes fonts larger.

I want to set them at size 14 and in Verdana style.

Type set tics font “Verdana, 14” and press Enter. Type this command as shown here, to change the font size and style.

Replot to see the result.

Hover mouse next to axis font. Notice the larger font size in Verdana style.
Type set xlabel 'x (angle)' font “Verdana, 14”

Press Enter

Let's set x axis label as x angle.

Type the command as shown here.

Here we are specifying the label, font style and size in a single command.

Type set ylabel 'sin (x)' font “Verdana, 14” and press Enter. To set y axis label as sin x, type the command, as shown here.
Cursor on the terminal. We are using the same font size and style for y axis too.
Type replot and press Enter Type replot and press Enter.
Cursor on the graph. Now, let’s see how to change the font in the legend.
Type set key font ",16" and

Press Enter

Type

set space key space font space within double quotes comma 16 .

This command sets the legend font size to 16.

Press Ctrl+Alt+K. I will clear the terminal.
Type help fonts and press Enter 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.
Type cairo and press Enter I will type cairo to see the details and available options.
Cursor on the terminal. Similarly you may choose to use help for any command when using gnuplot.
Mouse in Help section. You may pause the video and read the details given in the help section.
Press Ctrl C. Once done, press Control and C keys to exit the help section.
Ctrl+L in Ubuntu and Ctrl+Shift+K in Debian. I will clear the screen.

I wish to add a title to my graph.

Type set title 'My first gnuplot' and press Enter. To add a title, type set title command, as shown here.

Followed by the title of the graph in single quotes.

Type set title font "verdana, 18" and press Enter. To set the title font, type the command as shown here.
Point to x axis. In the sinx versus x plot, dimensions of x axis is angle.

Hence we may want to label X axis in terms of angle, π.

In the terminal, type,

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,) and press Enter.

To change X ticks to angle, type the following command as shown on the screen.

Here we are using the Greek alphabet pi and setting its position.

Point mouse to ('2{/Symbol p}' and then to 2*pi. This command places, Greek symbol pi, at the value of 3.14.

Label 2π is at position 6.28 on the X axis.

Point to and . Multiples of pi are placed at their respective positions.
Type help set xtics and press Enter. For more help on the formats of x tics, type the command help space set space xtics.
Press Ctrl C. Press Ctrl and C keys to exit the help section.
Press Ctrl+Shift+K in Debian. I will clear the terminal.
Cursor on the terminal. It is also possible to add multiple functions on the same graph.
Type plot sin(x), cos (x) and press Enter. To plot sin x and cos x on the same graph, separate the functions by a comma.

Type plot space sin x comma cos x.

Make sure that the angle x, is within parentheses.

Point to the graph window. Notice that the two functions are plotted together now.
Cursor on the terminal. Next, we will add sin (x) plus cos (x) function to the same graph.
Type plot sin(x), cos(x), sin(x) + cos(x) and press Enter. For this, type plot space sin(x) comma cos(x) comma sin(x) plus cos(x) .
Point to the graph window. Notice that all 3 functions are plotted together on the same graph window.

Next, let’s learn how to get sin(x) data points into a file.

Cursor on the terminal. To get an ASCII column format output, set table command can be used.
Type set space table and press Enter. First type set space table.
Enter command plot sin(x) and press Enter. Then type plot space sin(x).
Point to the screen An x y column data for sin(x) is generated on the screen.
Highlight first column.

Highlight second column.

The first column is x data and the second column is y data.

They are the points of sin x versus x graph.

Press Ctrl+Alt+K I will clear the terminal.

We can save the output as a text file.

Type set table "table-sinx.txt" and press Enter. For this, type set space table space within double quotes sinx dot txt.

Here sinx dot txt is the output filename.

Type plot sin(x) and press Enter. Then, type plot space sin(x).

The output is saved to the file sin x dot txt.

The data is not seen on the screen.

Show screenshot of Desktop showing the file sinx.txt. The file is stored in the directory from where we opened gnuplot in the terminal.
Type unset table and press Enter. Type unset space table to exit the tabular output mode.
Enter the command quit. Then type quit or q to quit gnuplot.
Slide Number 6

Summary

Let’s summarize.

In this tutorial,

  • we plotted 2D graphs of functions.

We also

  • Added grid and set limits
  • Zoomed in and zoomed out of a plot
  • Added axis labels and graph title
  • Changed font style and size

and

  • Saved the data points to a file
Slide Number 7

Assignment

As an assignment, plot the following functions:
  • tan x
  • x squared

and

  • x minus three squared
Show Completed assignment. Your completed assignment should look like this.
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 using spoken tutorials 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