<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://www.marcelpost.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Gnuplot</id>
	<title>Gnuplot - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.marcelpost.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Gnuplot"/>
	<link rel="alternate" type="text/html" href="https://www.marcelpost.com/wiki/index.php?title=Gnuplot&amp;action=history"/>
	<updated>2026-05-17T04:07:45Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.17</generator>
	<entry>
		<id>https://www.marcelpost.com/wiki/index.php?title=Gnuplot&amp;diff=2890&amp;oldid=prev</id>
		<title>Admin at 21:59, 19 October 2017</title>
		<link rel="alternate" type="text/html" href="https://www.marcelpost.com/wiki/index.php?title=Gnuplot&amp;diff=2890&amp;oldid=prev"/>
		<updated>2017-10-19T21:59:28Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Gnuplot is a portable command-line driven graphing utility for Linux, OS/2, MS Windows, OSX, VMS, and many other platforms.&lt;br /&gt;
&lt;br /&gt;
I have been using Gnuplot for some of my antenna-range measurements using a GPS module and a microcontroller.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The way I use it on Linux, there are four files required to create a new plot:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* data file&lt;br /&gt;
&lt;br /&gt;
[[File:Data-blur.jpg]]&lt;br /&gt;
&lt;br /&gt;
This is data in CSV (comma separated values) and the column numbers need to match what the Gnuplot script expects. A common format would be to have whatever you&amp;#039;re measuring (e.g. signal strength, or voltage) in the first column, gps latitude and longitude in the second and third columns, maybe elevation in the fourth column, and gps timestamps (usually in UTC format) in the fifth column. But once you have closer look in the gps.gnuplot.txt script file you should be able to change this around. The columns in the script file are referred to as $1, $2, $3, etc..&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* map image&lt;br /&gt;
&lt;br /&gt;
[[File:Demo-map-image-gnuplot.jpg]]&lt;br /&gt;
&lt;br /&gt;
A map in .png format of the area that covers the range where GPS measurements were made. Although not strictly required for generic Gnuplot use, I used a bash script as a pre-processor to feed the coordinates as read from the map image&amp;#039;s filename. This way no script files need to be edited, only the map image filename. The filename needs to contain the top-left and bottom-right coordinates in a specific order.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* plot-coverage-map.sh&lt;br /&gt;
&lt;br /&gt;
This is a Linux bash shell script that will run some checks to make sure that the input files exist and that the coordinates are found in the filename. It also allows for adjusting the position of the data on the map if the coordinates don&amp;#039;t exactly align. The script will scan the map image to get the dimensions and pass it on to gnuplot. The code for this file is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* gps.gnuplot.txt&lt;br /&gt;
&lt;br /&gt;
The script that contains all the functions to combine the data and the map and produce the resulting plot image. It uses various variables that are fed from the bash script so that this file needs very little editing to make plots for different input files. The code for this file is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NOTE: you may need to swap the latmin/latmax or lonmin/lonmax values if you&amp;#039;re in the northern hemisphere or west of Greenwich.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example final image with the data plotted, legend, title and axis labels.&lt;br /&gt;
&lt;br /&gt;
[[File:Demo-gnuplot-gps-map.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Since the data file and the map image are dependent on your preferences, I have only listed here the contents of the bash script and the gnuplot script.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===plot-coverage-map.sh===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
GNUPLOT=/usr/bin/gnuplot&lt;br /&gt;
PLOTFILE=gps.gnuplot.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# update these if the map coordinates don&amp;#039;t exactly match the data.&lt;br /&gt;
# values are in 100,000th arc decimals and can go negative&lt;br /&gt;
ADJUST_LAT=0&lt;br /&gt;
ADJUST_LON=0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# range of data values.&lt;br /&gt;
VALUES_MIN=10&lt;br /&gt;
VALUES_MAX=1024&lt;br /&gt;
&lt;br /&gt;
OUTFILE=&amp;quot;measurements-plotted.png&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# -- shouldn&amp;#039;t have to edit anything else below in this script --&lt;br /&gt;
&lt;br /&gt;
if test $# -lt 2&lt;br /&gt;
then&lt;br /&gt;
  echo &amp;quot;Syntax: $0 &amp;lt;mapfile_latmax,lonmax_latmin,lonmin.png&amp;gt; &amp;lt;datafile&amp;gt;&amp;quot;&lt;br /&gt;
  echo&lt;br /&gt;
  exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if ! test -f $1&lt;br /&gt;
then&lt;br /&gt;
  echo &amp;quot;File not found: $1&amp;quot;&lt;br /&gt;
  exit 1&lt;br /&gt;
fi&lt;br /&gt;
if ! test -f $2&lt;br /&gt;
then&lt;br /&gt;
  echo &amp;quot;File not found: $2&amp;quot;&lt;br /&gt;
  exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# echo fetch coordinates from map file&lt;br /&gt;
&lt;br /&gt;
LATMAX=`echo &amp;quot;$1&amp;quot; | awk -F _ &amp;#039;{print $2}&amp;#039; | awk -F , &amp;#039;{print $1}&amp;#039;`&lt;br /&gt;
if test -z $LATMAX&lt;br /&gt;
then&lt;br /&gt;
	echo &amp;quot;unable to get map Max Latitude, please check filename format&amp;quot;&lt;br /&gt;
	exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
LONMAX=`echo &amp;quot;$1&amp;quot; | awk -F _ &amp;#039;{print $2}&amp;#039; | awk -F , &amp;#039;{print $2}&amp;#039;`&lt;br /&gt;
if test -z $LONMAX&lt;br /&gt;
then&lt;br /&gt;
	echo &amp;quot;unable to get map Max Longitude, please check filename format&amp;quot;&lt;br /&gt;
	exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
LATMIN=`echo &amp;quot;$1&amp;quot; | awk -F _ &amp;#039;{print $3}&amp;#039; | awk -F , &amp;#039;{print $1}&amp;#039;`&lt;br /&gt;
if test -z $LATMIN&lt;br /&gt;
then&lt;br /&gt;
	echo &amp;quot;unable to get map Min Latitude, please check filename format&amp;quot;&lt;br /&gt;
	exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
LONMIN=`echo &amp;quot;$1&amp;quot; | awk -F _ &amp;#039;{print $3}&amp;#039; | awk -F , &amp;#039;{print $2}&amp;#039; | awk -F . &amp;#039;{print $1&amp;quot;.&amp;quot;$2}&amp;#039;`&lt;br /&gt;
if test -z $LONMIN&lt;br /&gt;
then&lt;br /&gt;
	echo &amp;quot;unable to get map Min Longitude, please check filename format&amp;quot;&lt;br /&gt;
	exit 1&lt;br /&gt;
fi&lt;br /&gt;
echo &amp;quot;Latmax: $LATMAX  Lonmax: $LONMAX&amp;quot;&lt;br /&gt;
echo &amp;quot;Latmin: $LATMIN  Lonmin: $LONMIN&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if test $ADJUST_LAT -ne 0&lt;br /&gt;
then&lt;br /&gt;
  echo &amp;quot;Adjusting Latitude by $ADJUST_LAT&amp;quot;&lt;br /&gt;
  LATMAX=`echo &amp;quot;scale=6;$LATMAX + ($ADJUST_LAT/1000000)&amp;quot; | bc`&lt;br /&gt;
  LATMIN=`echo &amp;quot;scale=6;$LATMIN + ($ADJUST_LAT/1000000)&amp;quot; | bc`&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if test $ADJUST_LON -ne 0&lt;br /&gt;
then&lt;br /&gt;
  echo &amp;quot;Adjusting Longitude by $ADJUST_LON&amp;quot;&lt;br /&gt;
  LONMAX=`echo &amp;quot;scale=6;$LONMAX + ($ADJUST_LON/1000000)&amp;quot; | bc`&lt;br /&gt;
  LONMIN=`echo &amp;quot;scale=6;$LONMIN + ($ADJUST_LON/1000000)&amp;quot; | bc`&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# get map file dimensions&lt;br /&gt;
&lt;br /&gt;
IMG_WIDTH=`file &amp;quot;$1&amp;quot; | awk -F &amp;quot;PNG image data, &amp;quot; &amp;#039;{print $2}&amp;#039; | awk &amp;#039;{print $1}&amp;#039;`&lt;br /&gt;
if test -z $IMG_WIDTH&lt;br /&gt;
then&lt;br /&gt;
	echo &amp;quot;unable to get image width, please check output from &amp;#039;file&amp;#039; command&amp;quot;&lt;br /&gt;
	exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
IMG_HEIGHT=`file &amp;quot;$1&amp;quot; | awk -F &amp;quot;PNG image data, &amp;quot; &amp;#039;{print $2}&amp;#039; | awk &amp;#039;{print $3}&amp;#039; | awk -F , &amp;#039;{print $1}&amp;#039;`&lt;br /&gt;
if test -z $IMG_HEIGHT&lt;br /&gt;
then&lt;br /&gt;
	echo &amp;quot;unable to get image height, please check output from &amp;#039;file&amp;#039; command&amp;quot;&lt;br /&gt;
	exit 1&lt;br /&gt;
fi&lt;br /&gt;
echo &amp;quot;dimensions: $IMG_WIDTH x $IMG_HEIGHT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;create graph..&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if $GNUPLOT -e &amp;quot;width=$IMG_WIDTH&amp;quot;         \&lt;br /&gt;
	    -e &amp;quot;height=$IMG_HEIGHT&amp;quot;       \&lt;br /&gt;
	    -e &amp;quot;latmax=$LATMAX&amp;quot;           \&lt;br /&gt;
	    -e &amp;quot;lonmax=$LONMAX&amp;quot;           \&lt;br /&gt;
	    -e &amp;quot;latmin=$LATMIN&amp;quot;           \&lt;br /&gt;
	    -e &amp;quot;lonmin=$LONMIN&amp;quot;           \&lt;br /&gt;
	    -e &amp;quot;values_min=$VALUES_MIN&amp;quot;   \&lt;br /&gt;
	    -e &amp;quot;values_max=$VALUES_MAX&amp;quot;   \&lt;br /&gt;
	    -e &amp;quot;MAP_FILE=&amp;#039;$1&amp;#039;&amp;quot;            \&lt;br /&gt;
	    -e &amp;quot;DATA_FILE=&amp;#039;$2&amp;#039;&amp;quot;           \&lt;br /&gt;
	    -e &amp;quot;OUT_FILE=&amp;#039;$OUTFILE&amp;#039;&amp;quot;      \&lt;br /&gt;
	    $PLOTFILE&lt;br /&gt;
then&lt;br /&gt;
  OK=1&lt;br /&gt;
else&lt;br /&gt;
  # some error occurred, keep the screen paused for a while longer&lt;br /&gt;
  sleep 2&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Done&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The second file is the gnuplot script file that does the actual plotting of the data on the background image:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===gps.gnuplot.txt===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/gnuplot&lt;br /&gt;
&lt;br /&gt;
reset&lt;br /&gt;
&lt;br /&gt;
set key off&lt;br /&gt;
&lt;br /&gt;
set term png size width,height&lt;br /&gt;
&lt;br /&gt;
# Data is comma delimited&lt;br /&gt;
set datafile separator &amp;quot;,&amp;quot;&lt;br /&gt;
&lt;br /&gt;
set output OUT_FILE&lt;br /&gt;
&lt;br /&gt;
set pm3d;&lt;br /&gt;
set pm3d map&lt;br /&gt;
&lt;br /&gt;
# initially, disable the colorbox so it isn&amp;#039;t generated with images and data plots&lt;br /&gt;
unset colorbox&lt;br /&gt;
&lt;br /&gt;
# vertical ticks on the colorbox&lt;br /&gt;
set cbtics&lt;br /&gt;
&lt;br /&gt;
set multiplot&lt;br /&gt;
&lt;br /&gt;
set lmargin at screen 0.1&lt;br /&gt;
set rmargin at screen 0.85&lt;br /&gt;
set bmargin at screen 0.1&lt;br /&gt;
set tmargin at screen 0.9&lt;br /&gt;
&lt;br /&gt;
set title &amp;quot;Enter a useful title here &amp;quot;&lt;br /&gt;
&lt;br /&gt;
# -- define the data point colors on the map --&lt;br /&gt;
&lt;br /&gt;
# option #1 - hand-pick two Hue values and let gnplot map the values to it&lt;br /&gt;
#h1 = 20/360.0&lt;br /&gt;
#h2 = 250/360.0&lt;br /&gt;
#set palette model HSV functions (1-gray)*(h2-h1)+h1,1,0.98&lt;br /&gt;
&lt;br /&gt;
# option #2 - simple two-color linear gradient&lt;br /&gt;
#set palette model RGB defined ( 0 &amp;#039;red&amp;#039;, 1 &amp;#039;blue&amp;#039; )&lt;br /&gt;
&lt;br /&gt;
# option #3 - skewed towards higher values&lt;br /&gt;
set palette model RGB defined ( 0 &amp;#039;yellow&amp;#039;, 600 &amp;#039;blue&amp;#039;, 800 &amp;#039;green&amp;#039;, 1024 &amp;#039;red&amp;#039; )&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# -- plot the background map --&lt;br /&gt;
unset xtics&lt;br /&gt;
unset ytics&lt;br /&gt;
plot MAP_FILE binary filetype=png with rgbimage notitle&lt;br /&gt;
&lt;br /&gt;
# -- plot the data on the map --&lt;br /&gt;
&lt;br /&gt;
#           west      east&lt;br /&gt;
set xrange [lonmax:lonmin]&lt;br /&gt;
#           south     north&lt;br /&gt;
set yrange [latmin:latmax]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set xtics .01 &lt;br /&gt;
set ytics .01 &lt;br /&gt;
set xlabel &amp;quot;Longitude&amp;quot;&lt;br /&gt;
set ylabel &amp;quot;Latitude&amp;quot;&lt;br /&gt;
plot DATA_FILE using 3:2:1 notitle with points lc palette&lt;br /&gt;
&lt;br /&gt;
# -- plot the color box --&lt;br /&gt;
set cbrange [values_min:values_max]&lt;br /&gt;
set cblabel &amp;quot;Signal Strength (0-1024)&amp;quot; offset 0.0,0.0&lt;br /&gt;
set zrange [0:1]&lt;br /&gt;
unset xlabel &lt;br /&gt;
unset ylabel&lt;br /&gt;
unset title&lt;br /&gt;
unset xtics&lt;br /&gt;
unset ytics&lt;br /&gt;
set colorbox vertical user origin 0.87,0.1 size 0.02,0.5&lt;br /&gt;
splot &amp;#039;++&amp;#039; u ($2):($3):(cos($2*$3)):($1) with pm3d &lt;br /&gt;
&lt;br /&gt;
unset multiplot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For the background map I just use google maps and do a print-screen of an area. I then right-click on the map to get the coordinates and put those for the top-left and bottom-right corners of the image into the filename.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>