Gplot Example

GPlot

Sometimes the simplest things can be remarkably difficult to get done. That was my reaction when I first tried to make a few simple plots. I knew about gnuplot, but it took way too long to make my first useful plot.

Perhaps the most frustrating task was trying to do something as simple (to me) as "plot this data with a blue line" or maybe the dauntingly (:-) complex "plot this data with a blue line using triangles for the data points". Eventually, I figured out one answer was this fragment:

set style line 10 lt 3 lw 1 pt 8 ps 0.55 plot 'my.data' with linespoints linestyle 10

Alright, I'm fed up! No more trying to figure out 'lt 3' versus 'lt 5' and 'pt 3' versus 'pt 22'! I just want a simple command I can understand that does what I want:

gplot.pl -color red -point triangle my.data

Sure gplot.pl can't handle the five or ten million complexities that gnuplot can -- but I don't care. All I want is a way to plot some simple columnar data and get a graphic or Postscript file of it and I don't want to spend very many seconds figuring it out. If this is what you want too, gplot.pl is for you too.


GPlot is available at SourceForge.

The latest version of GPlot is 1.11 and requires at least gnuplot 4.4. Every year or two the GNUPLOT folks change the syntax for some command or make some other change that is incompatible with an older release. GPLOT doesn't use very many GNUPLOT commands, but nonetheless, every few years, GPLOT breaks. Eventually I catch up, but it means the latest version of GPLOT might not work with your older GNUPLOT. The answer is to get an older GPLOT. Sorry :-(

Introduction

Gplot is a simple Perl script. It accepts a large set of options to generate a single plot of one or more sets of data (overlaid as necessary). The X and Y axis will be scaled automatically.

The options are provide in two categories. Most options apply to the entire plot (e.g. title) whereas a smaller set can be entered multiple times so that certain values can be set for each plot (e.g. color for each plot). This may require careful reading of the options listed below.

Additional information on using gnuplot is available at these locations (among many others):

Examples

The following examples will give you an idea of what Gplot can do. Take a look at the man page for Gplot for the complete set of options. In addition, here is the output of the regression test and will give you examples of many options. Here are examples of the more common uses.

  # plot data in '1a.data'. Show as X window
  gplot.pl   1a.data

  # plot 2 sets of data.  Show as X window
  gplot.pl   1a.data  2a.data

  # plot data in '1a.data'. Create a Postscript file /tmp/gplot.ps
  gplot.pl -type ps   1a.data

  # plot data in '1a.data'. Create a Postscript file
  gplot.pl -type ps -outfile 1a.ps   1a.data

  # plot data in '1a.data'. Annotate it a little
  gplot.pl -title "This is my data"  -ylabel "Vertical Axis" \
    -xlabel "Horizontal Axis"  1a.data

  # plot 3 sets of data, specify colors and points
  gplot.pl -color green -point uptriangle   1a.data \
           -color blue  -point box          2a.data \
           -color green -point circle       3a.data

  # 4 plots in a 2x2 matrix
  gplot.pl -mplot 2x2 -title Matrix_MultiPlot -using 1 0a.data \
           -using 1:2 1a.data 2a.data 3a.data

That should do it. The only file needed is the Perl script, gplot.pl. Copy that somewhere in your path and you should be good to go (assuming you have gnuplot installed).

One last surpise - not all output formats (X window, Postscript etc.) generate something that looks exactly the same. I test with '-type xwin' (the default), but the font and annotation stuff seldom looks like the final output for something like '-type ps'. That's the way life is with gnuplot - don't let it throw you.



Direct questions to: Terry Gliedt tpg@hps.com (Include 'GPlot' in the subject line so my SPAM filter lets your message through.)

This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. See http://www.gnu.org/copyleft/gpl.html