This is a script to plot streaming / real-time data (i.e. plot the points as the data comes in) with gnuplot. The script is written in perl and works in windows as well as linux. Please read on to see the requirements, installation, usage and download link. I should also thank my colleague Rabindra Mandal, who gave me the initial idea and Thanassis Tsiodras, whose script I looked at before creating mine (though mine is quite different in nature. Tsiodras’ script is for “moving” data like things with limitless ranges, while mine is more for data that has limitless occurences within a limited range as my main motivation behind it was to plot touchscreen data)


You are free to download, install, modify and use this script for any commercial/non-commercial purposes. However, if you modify the script and/or re-distribute it, I’d like to request you to keep the attribution to me as the author intact in the script as well as provide a credit/linkback to this page in associated files/webpages etc.

I’d also be happy if you can send me your modifications to fix any bugs or add new features and would be glad to incorporate them and host them here if you want.

You can also send in any bug reports or feature requests by posting a comment below.


  • Perl (Tested on v5.6.1 and v5.10. If you have linux, this might already be installed. For Windows, please click on the link.)

  • gnuplot (Tested with v 4.2.6)


  • Install the above mentioned requirements

  • Make sure that you can run “perl” and “gnuplot” commands (“pgnuplot” instead of “gnuplot” if you have windows) in your shell/command prompt. If you see an issue, add the path to the executables for these to your environment variables.

  • Download the below linked zip file and unzip it to any location (preferably to a place where you have write permissions as a normal user).


The script is named rtgnuplotter.pl. The various details regarding its usage are as below:

Input Parameters:

-xrange min:max (Optional) Horizantal Range
-yrange min:max (Optional) Vertical Range
-invertx        (Optional) Invert horizontal Axis
-inverty        (Optional) Invert Vertical Axis
-hex            (Optional) Input data is in hex (without leading 0x)
-joindots       (Optional) Data points are connected with lines
-h\\-help\\-v     (Optional) Print usage and version info</blockquote>

Input Data: The input data for rtgnuplotter is expected to be two space separated numbers, the first number being for x axis and second for y axis. Each set of coordinates denoting a point to be plotted should be on a new line. Hexadecimal as well as decimal numbers are supported. For Hexadecimal input, use the “-hex” option but the numbers should not have “0x” prefix.

Usage: All the options for rtgnuplotter are optional. You can run it with/without any options and it will wait for you to provide input on standard input. You can also pipe data into the script from another program using “|”. Few examples of the usage are:

perl rtgnuplotter.pl

tail -f mydata.log | grep --line-buffered “Data Points” | sed --unbuffered ‘s/.*x=\([0-9.-]*\).*y=\([0-9.-]*\).*/\1 \2/' | perl rtgnuplotter.pl</blockquote>

In the second example above, we get the data being written to a logfile by some other program, grep for the lines that have our points, then extract just the numbers with sed and then pass them to rtgnuplotter. Please note that “–line-buffered” and “–unbuffered” options used with grep and sed respectively, are important, otherwise you might not see your data being plotted immediately.

The zip file also contains a test file “inp.pl” that you can use to test the script. inp.pl generates some random numbers To run the test, just cd to the place where you unzipped the file and run the command line given in 2nd example in one command window and “perl inp.pl > temp.txt” in another.

Lost the files in a server move and not available anymore

See also