17. gnuplot for botanists.

gnuplot is an axis drawing program, that takes data in ASCII format, and produces fancy graphs. You will need X11 running and a text editor.

You write 2 files: a data file with lots of points, and a 5 line script with command to set the title, any options and name the data file. It really is very easy, but you will need to spend a few minutes selecting the correct options for point shapes, dotted lines, and such. The axes are automatically created, though you can specify them, eg to compare lots of graphs, with similar axes.

To get a printout, either snapshot the X11 window, or use one of the output formats.

17.1 Install
17.2 Points and functions
17.3 Examples and Demos
17.4 gnuplot world.dem
17.5 gnuplot all.dem
17.6 gnuplot.gih (120 k)
17.7 defaults.ini
17.8 Online-help
17.9 More help
17.10 Not Enough?

17.1

Install

I installed this as a pre-compiled package. For many people it is a standard component, and is already on your system.

According to it's own README, the GNU in gnuplot has nothing to do with GNU. Strange, but fair enough.

17.2

Points and functions

gnuplot can plot both points from your datafile, and functions, so that you can overlay a "best-fit" function against actual experimental functions.

You can use any programming language (eg awk, perl, C) to process your data, and write the files, just don't overwrite your original data with generated data!. Or you can type them in manually.

17.3

Examples and Demos

There are a several demo programs, and datafiles here. Might as well try a few.

cd to the demos directory, and run gnuplot filename the X11 window soon pops up.

To make effective use of your browser, open up a new browser window, to look at the files, (keep this one here), and combine that with a shell running in an xterm.

17.4

gnuplot world.dem

Up pops a flattened globe, then a transparent one, then a cylinder. This is probably much more complicated than most normal graphs, but it's fun, and worth seeing first.

world.dem (1414 bytes)

This is the program that sequences the demo, and draws the graphs. Notice how each graph only requires a few lines of gnuplot commands, and a seperate data file.

world.dat (17 k bytes)

This is the datafile with the approximate coastal outlines, in 3-d coordinates (latitude, longtitude). Not bad for 16k. Does it fill ??

world.cor (3485 including comments)

This is a list of points, marking city and university sites. It shows how to annotate specific points.

This file also shows how you could keep comments in datafiles, whilst still sorting and auto-editing the data files, ie, keep the comment and the point on the same line, sort by x or by y (sort +1), and the comments move with the points.

17.5

gnuplot all.dem

This cycles through some graphs, ranging from the sinusoidal, to the experimental. Goes through all variations of a type of graph. IE the main demo.

17.6

gnuplot.gih (120 k)

This is the online help topic documentation (except for man gnuplot). IE when you type "help topic", that ext comes from this file.

Although it is intended for use through the gnuplot interactive help command, it is almost directly readable, can save time to go through it all. Different distributions put it in different places, and since the following links are local, they won't all work!

It explains how to set titles on graphs, what kind of graphs are available, how to call math exprs. how to read files of data-points, and how to generate maths functions.

You can access it using less, or an editor that allows you to search for keywords. It can be run in another VC, whilst you browse the gnuplot command lines, and data files.

17.7

defaults.ini

This file is manually included in many demos using load "defaults.ini"

17.8

Online-help

see above (gnuplit.gih)

17.9

More help

Whilst I like Slackware, I also like the original packages. If you look on disk3, or prep.ai.mit.edu, you will find /cdrom/gnu/gnuplot-3.5.tar.gz, with loads of files and docs in there.

From the example gnuplot graphs, you should see that it can produce neat graphs from files of data points, and quick command lines. Type your data in, using a similar line-per-point format. Keep the data in the correct (sorted) sequence, and create a 1 line gnuplot program, maybe add a line or two for the titles.

17.10

Not Enough?

If you can't do it with gnuplot, what are you trying to do? However, if you have your own program that already knows about X,Y, axes, labels and such, but need to port it to X11, you should consider using Tcl/Tk, and generate a text-file tcl script that plots your data. Your program generates lots of drawing commands, and pipes that to wish, which draws them. Here is an example tcl/tk script.