Difference between revisions of "Gnuplot/C2/Plotting-datasets-from-file/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "'''Title of script''': <span style="color:#000000;">'''Plot</span><span style="color:#000000;">ting datasets from file'''</span> '''Author: '''Rani Parvathy '''Keywords:'''...")
 
Line 1: Line 1:
'''Title of script''': <span style="color:#000000;">'''Plot</span><span style="color:#000000;">ting datasets from file'''</span>
+
{|border=1
 +
|| Visual Cue
 +
|| Narration
  
'''Author: '''Rani Parvathy
+
|-
 +
|| '''Slide Number 1'''
 +
'''Title Slide '''
 +
'''Plotting datasets from file'''
 +
|| Welcome to the tutorial on '''Plotting datasets from file'''
  
'''Keywords:''' gnuplot, video tutorial, spoken tutorial, plot data from file, plot more than one graph, change line color, set key, set symbol size, month, year, date formatting
+
|-
 +
|| '''Slide Number 2'''
 +
'''Learning Objectives'''
 +
|| In this tutorial we will learn to,
 +
* Plot x-y graph from a dataset in a file
 +
* Add two plots in a graph
 +
* Write legend and set time stamp
 +
* Change line color
 +
* Set symbol style and size
 +
* Change axis format and label style
  
  
{| 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
+
'''System and Software Requirement'''
|-
+
|| To record this tutorial, I am using
| 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>
+
  
<div style="color:#000000;">'''Title Slide '''</div>
+
* Debian Linux 9 point 3
 +
* Gedit text editor 3.22.0 and
 +
* gnuplot 5.2.5
  
<div style="color:#000000;">'''Plotting datasets from file'''</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 datasets from 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 2'''</div>
+
|| '''Slide Number 4'''
 +
'''Pre-requisites'''
 +
|| To follow this tutorial, learner's must be familiar with,
 +
* Basic computer and internet skills
 +
* Concept of graphing
 +
and
 +
* High school level Mathematics skills
  
<div style="color:#000000;">'''Learning Objectives'''</div>
+
|-
 +
|| Go to '''Desktop'''
 +
|| Go to '''Desktop'''
 +
We will plot a graph from data in a text file '''data dot txt'''
 +
The file is provided with this tutorial.
  
 +
|-
 +
|| Show data.txt icon in Desktop directory.
 +
|| It is saved in the Desktop folder for me.
  
 +
|-
 +
|| Double click on the icon
 +
|| Double click on the file icon to open and view the file.
 +
File opens in '''gedit''' text editor for me
  
| 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 to,</div>
+
|-
 +
|| Hover over mouse over hash.
 +
|| Data has three columns.
 +
The first row consists of headers and starts with a hash
  
 +
|-
 +
||
 +
|| First column contain '''x''' data.
 +
2nd and 3rd columns are two sets of '''y''' data.
  
* <div style="color:#000000;">Plot x-y graph from a dataset in a file</div>
+
|-
* <div style="color:#000000;">Add two plots in a graph</div>
+
|| Click on x sign
* <div style="color:#000000;">Write legend and set time stamp</div>
+
|| Close the file by '''File''' > '''quit''' or click on the ''''x'''' sign
* <div style="color:#000000;">Change line color</div>
+
* <div style="color:#000000;">Set symbol style and size</div>
+
* <div style="color:#000000;">Change axis format and label style</div>
+
  
 +
|-
 +
|| '''Press ctrl+alt+t'''
 +
|| Press control alt t, keys together on keyboard, to open a 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;">'''Slide Number 3'''</div>
+
||  
 +
|| A '''terminal''' opens.
  
<div style="color:#000000;">'''System and Software Requirement'''</div>
+
|-
 +
|| '''cd Desktop'''
 +
|| Change directory to '''Desktop''' directory with command as seen on the screen.
  
 +
|-
 +
|| '''gnuplot''', clear screen,
 +
|| Type '''gnuplot''' in command prompt and press enter, to open '''gnuplot'''
 +
I will bring terminal plot to top of the screen for clarity
  
<div style="color:#000000;"></div>
+
|-
 +
|| Hight on screen,
 +
'''>plot "data.txt" using 1:2 title 'Y1''''
 +
|| First let's make a plot from '''x''' and '''y1''' data columns.
 +
Enter command as seen on the screen
  
<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>
+
|| '''replot'''
 +
|| Here we also added legend in the same command line
 +
A graphic window opens
 +
Next, let's make the symbol size larger
  
 +
|-
 +
|| Type '''set pointsize 1.5'''
 +
Press '''enter'''
 +
|| To set symbol point size, type '''set pointsize 1.5'''
 +
Press '''enter'''
  
<div style="color:#000000;">Debian Linux</div>
 
 
<div style="color:#000000;">Gedit 3.22.0 and</div>
 
 
<div style="color:#000000;">have 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 4'''</div>
+
|| '''replot'''
 +
|| Replot to see the updated graph
 +
You may pause the video and explore symbol size and choose a size of your choice
  
<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, '''Samson''' '''USB''' portable microphone was used.</div>
 
 
 
<div style="color:#000000;">The model number '''SAGOMIC'''</div>
 
 
 
<div style="color:#000000;">I bought it from '''amazon''' website, for about rupees four thousand</div>
 
 
 
<div style="color:#000000;">It may be available in other websites.</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>
+
||  
 +
|| Now, Say I want to compare both '''y1''' and '''y2''' data on '''x-axis'''
  
<div style="color:#000000;">'''Pre-requisites'''</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 follow this tutorial, learner's must be familiar with, </div>
 
 
 
<div style="color:#000000;">Basic computer and internet skills</div>
 
 
 
<div style="color:#000000;"><span style="background-color:transparent;">Have c</span><span style="background-color:transparent;">oncept of graphing </span></div>
 
 
<div style="color:#000000;">and </div>
 
 
<span style="background-color:transparent;color:#000000;">Have h</span><span style="background-color:transparent;color:#000000;">igh school </span><span style="background-color:transparent;color:#000000;">level</span><span style="background-color:transparent;color:#000000;"> </span><span style="background-color:transparent;color:#000000;">M</span><span style="background-color:transparent;color:#000000;">ath</span><span style="background-color:transparent;color:#000000;">ematics</span><span style="background-color:transparent;color:#000000;"> skill</span><span style="background-color:transparent;color:#000000;">s</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 6'''</div>
+
||'''plot "data.txt" using 1:2 title 'Y1' , "data.txt" using 1:3 title 'Y2''''
 +
|| For this purpose, use the plot command as above, in series, separated by a comma
 +
The command is shown on the screen.
  
<div style="color:#000000;">'''Pre-requisites'''</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;" | <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>
 
 
 
<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;">Go to '''Desktop'''</div>
+
||  
 +
|| Let's set '''y'''axis to '''logarithmic''' scale from linear next
  
 
 
| 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;">Go to '''desktop''' </div>
 
 
 
<div style="color:#000000;">We will plot a graph from data in a text file '''data dot txt''' </div>
 
 
 
<div style="color:#000000;">The file is provided with this tutorial.</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;" | Show data.txt icon in Desktop directory.
+
|| '''>set logscale y'''
| 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;" | It is saved in the Desktop folder for me.
+
'''replot'''
|-
+
|| Use command '''set space logscale space y''' to set '''logscale'''.
| 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;" | Double click on the icon
+
'''Replot''' to see the result.
| 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;">Double click on the file icon to open and view the file.</div>
+
  
 
<div style="color:#000000;">File opens in '''gedit''' text editor for me</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;" |  
+
|| Show in Graphic window
| 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;">Data has three columns.</div>
+
|| The '''exponential''' curve change to linear line due to the '''logarithmic''' scale
 
+
  
<div style="color:#000000;">The first row consists of headers and starts with a hash</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;" |  
+
|| >'''unset logscale y'''
| 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;">First column contain '''x''' data.</div>
+
|| To go back to linear scale for '''y axis''', use command, '''unset space logscale space y'''
  
 
<div style="color:#000000;">2<sup>nd</sup> and 3<sup>rd</sup> columns are two sets of '''y''' data.</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;" | Click on x sign
 
| 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;" | Close the file by '''File''' > '''quit''' or click on the ''''x'''' sign
 
|-
 
| 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+alt+t'''
 
| 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;" | Press control alt t, keys together on keyboard, to open a 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;" | 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;color:#000000;" | '''cd Desktop'''
 
| 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 directory to '''Desktop''' directory as seen 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;" | Depending on your operating system, please set 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;" | '''set term qt'''
+
|| >'''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;" | <div style="color:#000000;">I will type '''set space term space qt'''. </div>
+
|| Please '''replot''' to see the resulting change.
  
  
<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'''
+
|| '''plot "data.txt" using 1:3 with linespoints'''
| 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 '''gnuplot''' in command prompt and press enter, to open '''gnuplot'''</div>
+
|| Say, I desire to draw a line between data points for '''x''' and '''y2''' data set.
 +
I will use the command as seen on the screen.
  
 
<div style="color:#000000;">I will Press '''control L''' to bring terminal prompt to top of screen, for clarity.</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;" |
 
 
|-
 
|-
| 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;">Hight on screen, </div>
+
||  
 +
|| Add with lines points in the plot command itself.
  
<div style="color:#000000;">'''>plot "data.txt" using 1:2 title 'Y1''''</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;">First let's make a plot from '''x''' and '''y1''' data columns.</div>
 
 
 
<div style="color:#000000;">Enter command as seen on the screen </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;" | '''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;" | <div style="color:#000000;">'''Replot''' to see the graph</div>
+
|| Next, let's change few graph properties.
 +
Say, I want a larger size filled circle data points and color them blue.
  
 
<div style="color:#000000;">Here we also added legend in the same command line</div>
 
 
 
<div style="color:#000000;">A graphic window opens</div>
 
 
 
<div style="color:#000000;">Next, let's make symbol size larger</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;">Type '''set pointsize 1.5'''</div>
+
|| Highlight on screen
 
+
 
+
<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;">To set symbol point size, type '''set pointsize 1.5'''</div>
+
  
 +
>'''plot "data.txt" using 1:3 title 'Y2' with linespoint lc 'blue' lt 1 lw 2 pt 7 ps 1.5'''
 +
|| Enter the command, as seen on the screen.
 +
This changes color, point style and style line.
  
<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:none;padding:0.0382in;color:#000000;" | '''replot'''
+
|| Hover mouse next to '''lc'''
| 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;">Replot to see the updated graph</div>
+
|| Here, '''lc''' sets line color to '''blue. '''
 +
We can also use hexadecimal code for a chosen color.
  
 
<div style="color:#000000;">You may pause the video and explore symbol size and choose a size of your choice</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;" |  
+
|| Hover mouse over '''lw'''
| 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, Say I want to compare both '''y1''' and '''y2''' data on '''x-axis'''
+
|| And '''lLw 2''' sets line width to two
 
|-
 
|-
| 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;">Highlight </div>
+
|| Hover mouse next to '''pt'''
 +
|| '''Pt''' sets point type or symbol style to '''7, '''which is a filled circle.
  
<div style="color:#000000;">>'''plot "data.txt" using 1:2 title 'Y1' , "data.txt" using 1:3 title 'Y2''''</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 this purpose, use the plot command as above, in series, separated by a comma</div>
 
 
 
<div style="color:#000000;">The command is shown on the screen.</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;" |  
+
|| Hover mouse next '''ps'''
| 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 set '''y'''-axis to '''logarithmic''' scale from linear next
+
|| '''Ps''' sets point size or symbol size to 1.5
|-
+
| 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 logscale y'''</div>
+
  
<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;">Use command '''set space logscale space y''' to set '''logscale'''.</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;" |
+
|| Hover mouse on y-axis range
| 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 '''exponential''' curve change to linear line due to the '''logarithmic''' scale
+
|| We may wish to change the format for axis labels on many occasions.
|-
+
Here, the y-axis numbers are large.  
| 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 logscale y'''
+
| 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 go back to linear scale for '''y-axis''', use command, '''unset space logscale space y'''
+
|-
+
| 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;" | <div style="color:#000000;">Please '''replot''' to see the resulting change.</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:none;padding:0.0382in;color:#000000;" | '''plot "data.txt" using 1:3 with linespoints'''
+
||  
| 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;">Say, I desire to draw a line between data points for '''x''' and '''y2''' data set.</div>
+
|| We may want to use scientific notation.
 +
I will use set format command for this purpose.
  
 
<div style="color:#000000;">I will use the command as seen on the screen. </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:none;padding:0in;color:#000000;" | Add with lines points in the plot command itself.
 
 
|-
 
|-
| 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 format y'''
| style="background-color:#ffffff;border:1pt solid #000000;padding:0.0382in;" | <div style="color:#000000;">Next, let's change graph properties.</div>
+
|| Type set space format, followed by axis name.
 +
Here it is '''y'''.
  
 
<div style="color:#000000;">Say, I want a larger size filled circle data points and color them blue.</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;">Highlight on screen</div>
+
|| ''''%0.2e'''' and replot
 +
|| Follow it by percent sign 2 e within single quotes as in the video.
  
<div style="color:#000000;">>'''plot "data.txt" using 1:3 title 'Y2' with linespoint lc 'blue' lt 1 lw 2 pt 7 ps 1.5'''</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 the command, as seen on the screen.</div>
 
 
 
<div style="color:#000000;">This changes color, point style and </div>
 
 
<div style="color:#000000;">style 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;" | Hover mouse next to '''lc'''
+
||  
| 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;">Here, '''lc''' sets line color to '''blue. '''</div>
+
|| You may also use the following syntax for changing format and range.
  
 
<div style="color:#000000;">We can also use hexadecimal code for a chosen color.</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;" | Hover mouse over '''lw'''
+
|| >'''set yrange [1:1.5e5]''' and 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;" | '''Lw 2''' sets line width to two
+
|| Use '''set space yrange space 1 colon 1 point 5e5 in square braces'''  
|-
+
This also changes format of '''y axis'''
| 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 next to '''pt'''
+
| 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;" | '''Pt''' sets point type or symbol style to '''7, '''which is a filled circle.
+
|-
+
| 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 next '''ps'''
+
| 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;" | '''Ps''' sets point size or symbol size to 1.5
+
|-
+
| 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 may wish to change the format for axis labels on many occasions.
+
|-
+
| 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 y-axis range
+
| 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;" | Here, the y-axis numbers are large.
+
|-
+
| 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 may want to use scientific notation.
+
|-
+
| 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 use set format command for this purpose.
+
|-
+
| 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 format y'''
+
| 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 set space format, followed by axis name. </div>
+
 
+
  
<div style="color:#000000;">Here it is '''y'''.</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;" | ''''%0.2e''''
+
||'''clear 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;" | Follow it by percent sign 2 e within single quotes as in the video.
+
'''set border linewidth 2 lc 'red''''
|-
+
|| I will bring terminal prompt to top of the screen, for clarity.
| 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;" |
+
We can also change color of the border and the line width.
| 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 also use the following syntax for changing format and range.
+
The commands are shown 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;" | <div style="color:#000000;">>'''set yrange [1:1.5e5]'''</div>
+
  
 
<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;">Use '''set space yrange space 1 colon 1 point 5e5 in square braces''' </div>
 
 
 
<div style="color:#000000;">This also changes format of '''y axis'''</div>
 
 
 
<div style="color:#000000;">I will press '''control l''' to bring terminal prompt to top of the screen for clarity.</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 border linewidth 2 lc 'red''''
+
|| >'''set timestamp'''
| 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;">We can also change color of the border and line width.</div>
+
|| We may also want to have a time stamp with the graph.
 +
Type '''set space timestamp''' to add time stamp
  
 
<div style="color:#000000;">The commands are shown on the screen.</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;" | We may also want to have a time stamp with 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;" | >'''set timestamp'''
 
| 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 '''set space timestamp''' to add time stamp
 
 
|-
 
|-
| 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 time stamp for the plot is displayed on bottom of the plot
+
|| Notice time stamp for the plot is displayed on bottom of the plot
 
|-
 
|-
| 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>
+
|| '''Slide Number 5'''
 
+
'''Summary'''
<div style="color:#000000;">'''Summary'''</div>
+
|| To summarize, in this tutorial, we  
 
+
* Plotted data from a file
 
+
* Added two plots in a graph
 
+
* Wrote legend title
| 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  
+
* Changed line color
 
+
 
+
* <div style="color:#000000;">Plotted data from a file</div>
+
* <div style="color:#000000;">Added two plots in a graph</div>
+
* <div style="color:#000000;">Wrote legend title</div>
+
* <div style="color:#000000;">Changed line color</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 8'''</div>
+
|| '''Slide Number 6'''
 
+
'''Summary'''
<div style="color:#000000;">'''Summary'''</div>
+
|| * Learned to change symbol style and size
 
+
* Formatted axis type and label style
 
+
* Changed border line color<br/>and
 
+
* Learned to set time stamp
| 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;">Learned to change symbol style and size</div>
+
* <div style="color:#000000;">Formatted axis type and label style</div>
+
* <div style="color:#000000;">Changed border line color</div><br/><div style="color:#000000;">and</div>
+
* <div style="color:#000000;">Learned to set time stamp</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 7'''
 +
'''Summary'''
 +
|| For assignment activity, please do the following,
 +
* Explore numbers 0-10 for color choice for line
 +
* Explore symbol styles for number choice 0-9
  
<div style="color:#000000;">'''Summary'''</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 activity, please do the following, </div>
 
 
 
* <div style="color:#000000;">Explore numbers 0-10 for color choice for line</div>
 
* <div style="color:#000000;">Explore symbol styles for number choice 0-9</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:none;padding:0.0382in;" | <div style="color:#000000;">'''Slide Number 10'''</div>
+
|| '''Slide Number 8'''
 +
'''Spoken Tutorial Project'''
 +
|| This video summarizes the Spoken Tutorial Project
 +
Please download and watch it.
  
<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 summari</span><span style="color:#000000;">z</span><span style="color:#000000;">es 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 9'''
 +
'''Spoken Tutorial workshops'''
 +
|| We conduct workshops and give certificates.
 +
Please write to us.
  
<div style="color:#000000;">'''Spoken Tutorial workshops'''</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;" | <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 10'''
  
<div style="color:#000000;">'''Forum for specific questions:'''</div>* <div style="color:#000000;margin-left:0in;margin-right:0in;"></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;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>
+
|| '''Slide Number 11'''
 
+
'''Acknowledgement'''
<span style="color:#000000;">'''Acknowledgemen'''</span><span style="color:#000000;">t</span>
+
|| Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India.
 
+
 
+
 
+
| 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;" | Thank you for joining.
+
|| Thank you for joining.
 
|-
 
|-
 
|}
 
|}
<div style="color:#000000;margin-left:0in;margin-right:0in;"></div>
 

Revision as of 17:25, 22 February 2019

Visual Cue Narration
Slide Number 1

Title Slide Plotting datasets from file

Welcome to the tutorial on Plotting datasets from file
Slide Number 2

Learning Objectives

In this tutorial we will learn to,
  • Plot x-y graph from a dataset in a file
  • Add two plots in a graph
  • Write legend and set time stamp
  • Change line color
  • Set symbol style and size
  • Change axis format and label style


Slide Number 3

System and Software Requirement

To record this tutorial, I am using
  • Debian Linux 9 point 3
  • Gedit text editor 3.22.0 and
  • gnuplot 5.2.5
Slide Number 4

Pre-requisites

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

and

  • High school level Mathematics skills
Go to Desktop Go to Desktop

We will plot a graph from data in a text file data dot txt The file is provided with this tutorial.

Show data.txt icon in Desktop directory. It is saved in the Desktop folder for me.
Double click on the icon Double click on the file icon to open and view the file.

File opens in gedit text editor for me

Hover over mouse over hash. Data has three columns.

The first row consists of headers and starts with a hash

First column contain x data.

2nd and 3rd columns are two sets of y data.

Click on x sign Close the file by File > quit or click on the 'x' sign
Press ctrl+alt+t Press control alt t, keys together on keyboard, to open a terminal
A terminal opens.
cd Desktop Change directory to Desktop directory with command as seen on the screen.
gnuplot, clear screen, Type gnuplot in command prompt and press enter, to open gnuplot

I will bring terminal plot to top of the screen for clarity

Hight on screen,

>plot "data.txt" using 1:2 title 'Y1'

First let's make a plot from x and y1 data columns.

Enter command as seen on the screen

replot Here we also added legend in the same command line

A graphic window opens Next, let's make the symbol size larger

Type set pointsize 1.5

Press enter

To set symbol point size, type set pointsize 1.5

Press enter

replot Replot to see the updated graph

You may pause the video and explore symbol size and choose a size of your choice

Now, Say I want to compare both y1 and y2 data on x-axis
plot "data.txt" using 1:2 title 'Y1' , "data.txt" using 1:3 title 'Y2' For this purpose, use the plot command as above, in series, separated by a comma

The command is shown on the screen.

Let's set yaxis to logarithmic scale from linear next
>set logscale y

replot

Use command set space logscale space y to set logscale.

Replot to see the result.

Show in Graphic window The exponential curve change to linear line due to the logarithmic scale
>unset logscale y To go back to linear scale for y axis, use command, unset space logscale space y
>replot Please replot to see the resulting change.


plot "data.txt" using 1:3 with linespoints Say, I desire to draw a line between data points for x and y2 data set.

I will use the command as seen on the screen.

Add with lines points in the plot command itself.
Next, let's change few graph properties.

Say, I want a larger size filled circle data points and color them blue.

Highlight on screen

>plot "data.txt" using 1:3 title 'Y2' with linespoint lc 'blue' lt 1 lw 2 pt 7 ps 1.5

Enter the command, as seen on the screen.

This changes color, point style and style line.

Hover mouse next to lc Here, lc sets line color to blue.

We can also use hexadecimal code for a chosen color.

Hover mouse over lw And lLw 2 sets line width to two
Hover mouse next to pt Pt sets point type or symbol style to 7, which is a filled circle.
Hover mouse next ps Ps sets point size or symbol size to 1.5
Hover mouse on y-axis range We may wish to change the format for axis labels on many occasions.

Here, the y-axis numbers are large.

We may want to use scientific notation.

I will use set format command for this purpose.

>Set format y Type set space format, followed by axis name.

Here it is y.

'%0.2e' and replot Follow it by percent sign 2 e within single quotes as in the video.
You may also use the following syntax for changing format and range.
>set yrange [1:1.5e5] and replot Use set space yrange space 1 colon 1 point 5e5 in square braces

This also changes format of y axis

clear screen

set border linewidth 2 lc 'red'

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

We can also change color of the border and the line width. The commands are shown on the screen.

>set timestamp We may also want to have a time stamp with the graph.

Type set space timestamp to add time stamp

Notice time stamp for the plot is displayed on bottom of the plot
Slide Number 5

Summary

To summarize, in this tutorial, we
  • Plotted data from a file
  • Added two plots in a graph
  • Wrote legend title
  • Changed line color
Slide Number 6

Summary

* Learned to change symbol style and size
  • Formatted axis type and label style
  • Changed border line color
    and
  • Learned to set time stamp
Slide Number 7

Summary

For assignment activity, please do the following,
  • Explore numbers 0-10 for color choice for line
  • Explore symbol styles for number choice 0-9
Slide Number 8

Spoken Tutorial Project

This video summarizes 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.
Thank you for joining.

Contributors and Content Editors

Madhurig, Ranipv076, Snehalathak