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..."
  exit
endif
if ("a$1" == "ahelp") then
  echo "Usage: $0   [numcols]"
  echo ""
  exit
endif
if ("a$2" == "a") then
set numcols=2
else
set numcols=$2
endif
#
#
set cnum=2
set pltcmd="plot '$1' using 1:2"
while ( $cnum != $numcols )
@ cnum = $cnum + 1
set pltcmd="${pltcmd}, '$1' using 1:${cnum}"
end
#
echo "Plot cmd: $pltcmd"
#
cat << EOF > x.plot.$$
set style data linespoints
$pltcmd
pause -1 "Hit return to continue"
EOF
#
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

plot1

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

plot2

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.

Advertisements

2 comments

  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 )

Google+ photo

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

Connecting to %s