<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://script.spoken-tutorial.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=Gnuplot%2FC4%2FMatrices-and-Contours%2FEnglish</id>
		<title>Gnuplot/C4/Matrices-and-Contours/English - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=Gnuplot%2FC4%2FMatrices-and-Contours%2FEnglish"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Gnuplot/C4/Matrices-and-Contours/English&amp;action=history"/>
		<updated>2026-05-01T05:12:24Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.17</generator>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=Gnuplot/C4/Matrices-and-Contours/English&amp;diff=54567&amp;oldid=prev</id>
		<title>Ranipv076: Created page with &quot; {| border=1 || '''Visual Cue''' || '''Narration'''  |-  || '''Slide Number 1'''  '''Title Slide''' || Welcome to the tutorial on '''Matrices and Contours'''  |-  || '''Slide...&quot;</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Gnuplot/C4/Matrices-and-Contours/English&amp;diff=54567&amp;oldid=prev"/>
				<updated>2020-12-08T13:38:30Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot; {| border=1 || &amp;#039;&amp;#039;&amp;#039;Visual Cue&amp;#039;&amp;#039;&amp;#039; || &amp;#039;&amp;#039;&amp;#039;Narration&amp;#039;&amp;#039;&amp;#039;  |-  || &amp;#039;&amp;#039;&amp;#039;Slide Number 1&amp;#039;&amp;#039;&amp;#039;  &amp;#039;&amp;#039;&amp;#039;Title Slide&amp;#039;&amp;#039;&amp;#039; || Welcome to the tutorial on &amp;#039;&amp;#039;&amp;#039;Matrices and Contours&amp;#039;&amp;#039;&amp;#039;  |-  || &amp;#039;&amp;#039;&amp;#039;Slide...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
{| border=1&lt;br /&gt;
|| '''Visual Cue'''&lt;br /&gt;
|| '''Narration'''&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| '''Slide Number 1'''&lt;br /&gt;
&lt;br /&gt;
'''Title Slide'''&lt;br /&gt;
|| Welcome to the tutorial on '''Matrices and Contours'''&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| '''Slide Number 2'''&lt;br /&gt;
&lt;br /&gt;
'''Learning Objectives'''&lt;br /&gt;
|| In this tutorial, we will&lt;br /&gt;
&lt;br /&gt;
* Plot a 2D matrix heatmap&lt;br /&gt;
* Read file headers for axis tics&lt;br /&gt;
* Plot a heat map for the matrix&lt;br /&gt;
* Add contours in a 3D plot and&lt;br /&gt;
* Label the contours&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| &lt;br /&gt;
&lt;br /&gt;
'''Slide Number 3'''&lt;br /&gt;
&lt;br /&gt;
'''System and Software Requirement'''&lt;br /&gt;
|| To record this tutorial, I am using&lt;br /&gt;
&lt;br /&gt;
* '''Ubuntu Linux''' v 16.04 OS&lt;br /&gt;
* '''gnuplot''' 5.2.6 and&lt;br /&gt;
* '''Gedit''' 3.18&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| &lt;br /&gt;
&lt;br /&gt;
'''Slide Number 4'''&lt;br /&gt;
&lt;br /&gt;
'''Pre-requisites'''&lt;br /&gt;
&lt;br /&gt;
[https://www.spoken-tutorial.org/ https://www.spoken-tutorial.org]&lt;br /&gt;
|| To follow this tutorial,&lt;br /&gt;
&lt;br /&gt;
* Learners must be familiar with the basics of '''gnuplot'''.&lt;br /&gt;
* Please visit this site for pre-requisite tutorials.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| '''Slide Number 5'''&lt;br /&gt;
&lt;br /&gt;
'''Code files'''&lt;br /&gt;
|| * Files used in this tutorial are provided in the '''Code files''' link of this tutorial.&lt;br /&gt;
* Please download and extract them. &lt;br /&gt;
* Make a copy and then use them while practising.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Screenshot of '''Desktop''' showing input file.&lt;br /&gt;
|| I have saved the input file '''results.txt '''on '''Desktop'''.&lt;br /&gt;
&lt;br /&gt;
Let’s check file format by opening the file in '''gedit''' text editor.&lt;br /&gt;
&lt;br /&gt;
You may use the editor of your choice.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Show '''results.txt''' file in text editor.&lt;br /&gt;
&lt;br /&gt;
Point to headers and matrix elements.&lt;br /&gt;
|| The first row is row header.&lt;br /&gt;
&lt;br /&gt;
The first row is headers referring to students from S1 to S20.&lt;br /&gt;
&lt;br /&gt;
First column is also a header. It lists the subjects they appeared for exam.&lt;br /&gt;
&lt;br /&gt;
The matrix elements are the marks obtained.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Close '''gedit'''.&lt;br /&gt;
|| Let’s close the text editor.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Press '''Ctrl+Alt+T'''.&lt;br /&gt;
|| I will also open a '''terminal'''.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type '''cd Desktop''' and press '''Enter'''.&lt;br /&gt;
|| Change the '''directory''' to '''desktop'''.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Enter the command '''gnuplot'''.&lt;br /&gt;
|| Open '''gnuplot''' from the '''terminal'''.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Press '''Ctrl+L'''.&lt;br /&gt;
|| I will also clear the screen.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type,&lt;br /&gt;
&lt;br /&gt;
'''plot 'results.txt' matrix rowheaders columnheaders with image'''&lt;br /&gt;
&lt;br /&gt;
and press '''Enter'''.&lt;br /&gt;
|| Enter the plot command as seen on the screen.&lt;br /&gt;
&lt;br /&gt;
Here, the matrix name '''results.txt''', is in single quotes.&lt;br /&gt;
&lt;br /&gt;
Use the syntax and whitespaces as seen on the screen for the command.&lt;br /&gt;
&lt;br /&gt;
Follow it with matrix, rowheaders, column headers.&lt;br /&gt;
&lt;br /&gt;
Specify to plot '''with image''' and press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Show graphics window.&lt;br /&gt;
|| In the graphics window, a 2D heatmap image of the matrix appears.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Hover mouse over '''x''' and '''y''' tics&lt;br /&gt;
|| The x and y axes tics are represented by strings.&lt;br /&gt;
&lt;br /&gt;
They are the student names.&lt;br /&gt;
&lt;br /&gt;
The subjects which they have appeared for examination is also seen.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Cursor on the color scale bar.&lt;br /&gt;
|| Notice the palette setting is indicated in the color scale bar.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Hover mouse over color scale bar.&lt;br /&gt;
|| The '''color palette''' can be customized as desired.&lt;br /&gt;
&lt;br /&gt;
Let’s change to a custom palette.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type,&lt;br /&gt;
&lt;br /&gt;
'''set palette defined (0 &amp;quot;dark-violet&amp;quot;, 1 &amp;quot;sandybrown&amp;quot;, 2 &amp;quot;grey80&amp;quot;, 3 &amp;quot;blue&amp;quot;, 4 0.5 1 0.5, 5 1 1 0, 6 1 0.5 0, 7 1 0 0, 8 0.5 0 0)''' and press '''Enter'''.&lt;br /&gt;
|| Now I will define a new color palette.&lt;br /&gt;
&lt;br /&gt;
Type the following command and press Enter.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Hover mouse over '''2 “grey80”''' and '''5 1 1 0''' .&lt;br /&gt;
|| Here, I define the color for each range in the colorbar.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type, '''replot''' and&lt;br /&gt;
&lt;br /&gt;
press '''Enter'''.&lt;br /&gt;
|| '''Replot''' to see the results.&lt;br /&gt;
&lt;br /&gt;
You may explore more on '''color palette''' options if desired.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Write on the Screen, Use the command, '''help color palette.'''&lt;br /&gt;
|| Use the command, '''help color palette''' for learning further.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Go to '''gnuplot terminal''' prompt.&lt;br /&gt;
|| Go back to the '''terminal'''.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type '''help palette''' and press '''Enter'''.&lt;br /&gt;
|| Use the command '''help palette''' to learn more about palette setting.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Press '''Ctrl+L'''.&lt;br /&gt;
|| I will clear the screen.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Cursor on the graphics window.&lt;br /&gt;
|| Let’s now plot contours and label the contours in a 3D plot.&lt;br /&gt;
&lt;br /&gt;
I will open '''gedit''' text editor to write a short script.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Cursor on '''gedit '''text window.&lt;br /&gt;
|| You may open the text editor of your choice.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type '''#contour plot and labels'''&lt;br /&gt;
&lt;br /&gt;
and press '''Enter'''.&lt;br /&gt;
|| First, write a comment line, starting with a hash, as seen here.&lt;br /&gt;
&lt;br /&gt;
Next let's incorporate contours in the plot.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type, '''set contour base''' and press '''Enter'''.&lt;br /&gt;
|| Then set the contour base with the command, '''set contour base'''.&lt;br /&gt;
&lt;br /&gt;
'''Set contour''' command is used for grid type data and is used with '''splot''' command.&lt;br /&gt;
&lt;br /&gt;
Here, '''base''' specifies that, the contours are drawn on the grid base.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type, '''set isosamples 50,50 '''and press '''Enter'''.&lt;br /&gt;
|| Set the grid for '''isosamples''' to 50 comma 50.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type, '''set style increment default''' and press '''Enter'''.&lt;br /&gt;
|| Set the increment to default value.&lt;br /&gt;
&lt;br /&gt;
This increments successive line styles in the graph.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type, '''set cntrparam levels auto 10''' and press '''Enter'''.&lt;br /&gt;
|| This command determines the z values for which the contours are to be drawn.&lt;br /&gt;
&lt;br /&gt;
We can also specify the way contours are drawn.&lt;br /&gt;
&lt;br /&gt;
Let’s also set the contour levels. I will set it to autoscale.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type, '''set cntrlabel format '%8.3g' font ',7' start 5 interval 20''' and press '''Enter'''.&lt;br /&gt;
|| Now, specify a desired font for the contour label, start and the interval.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type, '''set style data lines''' and press '''Enter'''.&lt;br /&gt;
|| Set the style to lines for the contours.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type '''set autoscale''' and press '''Enter'''.&lt;br /&gt;
|| Set axis range for x and y axis as seen here.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type, '''splot x**2+y**2 with lines notitle , x**2+y**2 with labels''' and press '''Enter'''.&lt;br /&gt;
|| Now, let’s draw the plot with '''splot''' command.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Press '''Ctrl+S'''.&lt;br /&gt;
|| I will save the file. Press '''Ctrl+S'''.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Give file name '''contour.dem''' in '''Desktop''' directory.&lt;br /&gt;
&lt;br /&gt;
Click on '''Save'''.&lt;br /&gt;
|| I will give file name '''contour.dem'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Save the file in '''Desktop''' directory.&lt;br /&gt;
|- &lt;br /&gt;
|| Minimize '''gedit''' and to the '''terminal'''.&lt;br /&gt;
|| Minimize '''gedit''' and go to the '''terminal'''.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type, '''cd Desktop '''and press '''Enter'''.&lt;br /&gt;
|| I will change the directory to '''Desktop'''.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type, '''gnuplot''' and press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
Press '''Ctrl+L'''.&lt;br /&gt;
|| I will also open '''gnuplot''' and clear the '''terminal'''.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type, '''load 'contour.dem' '''and press '''Enter'''.&lt;br /&gt;
|| Let’s load the script file with the '''load '''command as seen on the screen.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Cursor on the graphics window, on the surface.&lt;br /&gt;
|| The graphics window opens.&lt;br /&gt;
&lt;br /&gt;
Notice the surface plot.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Cursor on the contours.&lt;br /&gt;
|| The contours are seen on the base as we specified in the script file.&lt;br /&gt;
&lt;br /&gt;
They are also labeled.&lt;br /&gt;
&lt;br /&gt;
Let’s modify the script file to write the 3D data to a table.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Close the graphics window.&lt;br /&gt;
|| Close the graphics window.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Go to the script file.&lt;br /&gt;
|| Go back to the script file which is open in '''gedit''' text editor.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type, '''pause -1 'Press enter to continue'''' and press '''Enter'''.&lt;br /&gt;
|| I will add a '''pause''' command as seen on the screen.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type, '''set table 'contour.dat'''' and press '''Enter'''.&lt;br /&gt;
|| Next set table and specify an output file name.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type, '''splot x**2+y**2''' and press '''Enter'''.&lt;br /&gt;
|| Let’s '''splot''' the function as seen.&lt;br /&gt;
&lt;br /&gt;
This will generate data points in the specified file name.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type, '''unset table''' and press '''Enter'''.&lt;br /&gt;
|| Unset the table as seen on the screen.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Cursor on the '''graphics '''window.&lt;br /&gt;
|| Usually the plot will appear small if we '''splot '''the function directly.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type,&lt;br /&gt;
&lt;br /&gt;
'''set xrange [-9:9]'''&lt;br /&gt;
&lt;br /&gt;
'''set yrange [-9:9]'''&lt;br /&gt;
and press '''Enter'''.&lt;br /&gt;
|| I will also set '''x''' and '''y''' axis range.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type, '''plot 'table-contour.txt' using 1:2:3 with lines, '' u 1:2:3 every 50 w labels notitle''' and press '''Enter'''.&lt;br /&gt;
|| Next, plot the contours with the 2D '''plot''' command as seen.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Save the file, minimize '''gedit''' and go to the '''terminal'''.&lt;br /&gt;
|| Save the file, minimize '''gedit''' and go to the '''terminal'''.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Enter the command '''gnuplot'''.&lt;br /&gt;
|| Open '''gnuplot''' from the '''terminal'''.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Enter command '''load 'contour.dem'''' .&lt;br /&gt;
|| Load the script file as seen on the screen.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Cursor on the graphics window.&lt;br /&gt;
|| Notice the first plot which we saw earlier.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Go to the '''terminal''' and press '''Enter'''.&lt;br /&gt;
|| Go to the '''terminal''' and press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Cursor on the graphics window.&lt;br /&gt;
|| Notice the 2D contour plot.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Cursor on the graphics window.&lt;br /&gt;
|| Learner is encouraged to lookup the details for '''dgrid3d''' command.&lt;br /&gt;
&lt;br /&gt;
Use the '''help''' command in '''terminal''' for this purpose.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Close the graphics window.&lt;br /&gt;
|| Close the graphics window.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type '''help dgrid3d''' and press '''Enter'''.&lt;br /&gt;
|| In the '''terminal''' type '''help dgrid3d''' to access the help documentation on it.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Press '''Ctrl+C'''.&lt;br /&gt;
|| Learner may pause the video and explore the details.&lt;br /&gt;
&lt;br /&gt;
Let’s exit the help section by pressing '''Control-C'''.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Type '''q''' and press '''Enter'''.&lt;br /&gt;
|| Enter the command '''q''' or '''quit''' to quit '''gnuplot'''.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Close the '''gedit''' window.&lt;br /&gt;
|| Close the '''gedit''' window.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| '''Slide Number 6'''&lt;br /&gt;
&lt;br /&gt;
'''Summary'''&lt;br /&gt;
|| Now let's summarize.&lt;br /&gt;
&lt;br /&gt;
In this tutorial, we learned,&lt;br /&gt;
&lt;br /&gt;
* About a 2D matrix&lt;br /&gt;
* Plotted the data in the 2D matrix as heatmap&lt;br /&gt;
* Plotted, a 3D function with contours on the base with splot command&lt;br /&gt;
* Labeled the contours&lt;br /&gt;
* Plotted the contours of the 3D function in a 2D plot&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| '''Slide Number 7'''&lt;br /&gt;
&lt;br /&gt;
'''Assignment'''&lt;br /&gt;
|| For assignment activity, please do the following.&lt;br /&gt;
&lt;br /&gt;
For the function x2*y2, &lt;br /&gt;
* Change '''rgbformulae''' setting to change colors&lt;br /&gt;
* Plot contours with '''set contour surface''' and with '''set base both'''&lt;br /&gt;
* Notice the position of the contours that is plotted.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| '''Assignment picture'''&lt;br /&gt;
|| The completed assignment may look similar to this.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| '''Slide Number 8'''&lt;br /&gt;
&lt;br /&gt;
'''Spoken Tutorial Project'''&lt;br /&gt;
|| This video summarises the '''Spoken Tutorial''' Project.&lt;br /&gt;
&lt;br /&gt;
Please download and watch it.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| '''Slide Number 9'''&lt;br /&gt;
&lt;br /&gt;
'''Spoken Tutorial workshops'''&lt;br /&gt;
|| The '''Spoken Tutorial''' Project Team &lt;br /&gt;
* conducts workshops and&lt;br /&gt;
* gives certificates.&lt;br /&gt;
&lt;br /&gt;
For more details, please write to us.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| '''Slide Number 10'''&lt;br /&gt;
&lt;br /&gt;
'''Forum for specific questions:'''&lt;br /&gt;
|| Post your timed queries in the forum.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| '''Slide Number 11'''&lt;br /&gt;
&lt;br /&gt;
'''Acknowledgement'''&lt;br /&gt;
|| '''Spoken Tutorial''' Project is funded by MHRD, Government of India.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| &lt;br /&gt;
|| This is Rani from '''IIT, Bombay'''.&lt;br /&gt;
&lt;br /&gt;
Thank you for joining.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Ranipv076</name></author>	</entry>

	</feed>