a fast script: gplot.csh – quick plotting with gnuplot

This is a simple script which I use often to quickly visualize data. It is in my ~/bin directory since years, so I give it a chance to go public šŸ˜‰

#! /bin/tcsh
if ("a$1" == "a") then
  echo "give a file name..."
if ("a$1" == "ahelp") then
  echo "Usage: $0   [numcols]"
  echo ""
if ("a$2" == "a") then
set numcols=2
set numcols=$2
set cnum=2
set pltcmd="plot '$1' using 1:2"
while ( $cnum != $numcols )
@ cnum = $cnum + 1
set pltcmd="${pltcmd}, '$1' using 1:${cnum}"
echo "Plot cmd: $pltcmd"
cat << EOF > x.plot.$$
set style data linespoints
pause -1 "Hit return to continue"
gnuplot x.plot.$$
rm x.plot.$$

As example, I use this file:

[mariotti@localhost gplot]$ tail x.data
934 448 934
935 480 935
936 484 936
937 490 937
938 493 938
939 518 939
940 540 940
941 636 941
942 685 942
943 737 943

Then just type: “gplot.csh x.data” to get


or type “gplot.csh x.data 3” to get


I know it is in c-shell (actually I call tcsh) which is not anymore so used, but you can still install it. It is not a so bad thing to do šŸ˜‰

I use this script for very quickĀ visualizationĀ from the command line when I need to have an idea about the data, hope it helps.


  1. Pingback: Some unix commands I want to remember and an example from recsys « FM Techottis

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.