Filled boxes with gnuplot

One FAQ on the comp.graphics.apps.gnuplot newsgroup is, how to produce barcharts with filled boxes using gnuplot. It might be in development versions of gnuplot after 3.7.1, but until this is released I am aware of the following solutions:

Postprocess postscript output

Perl script by Andreas Widman. An enchanged version exists by Felix Ritter: The script draws boxed keys, and fills (and outlines) boxes by post-processing gnuplot postscript output. Can be found in ftp://ftp.gnuplot.org/pub/gnuplot/contrib/(leave) named boxfill.

This workaround is newer (Sept 2000?) as the other two solutions. If you only need postscript output it is probably simpler to use then going over fig, but if you do postprocessing anyway or need other formats the route over fig might be more flexible. (The script was not tested by me so far.)

Postprocess fig output

Use a small awk script I have created, which postprocesses output of the "fig" terminal. You can use a recent fig2dev (from the transfig package, always a compainion of xfig) to produce png, gif or eps images like the following:
[demo barchart;black and white; pattern filled] [demo color barchart]

Another possibility is to further process the resulting fig format file, e.g. using an vector graphics editor like XFIG and adding further details. Learn more about XFIG, FIG and associated software(leave).

You can get the package itself: barchart_via_fig-0.8.tar.gz or have a look at the barchart_via_fig-0.8.readme.txt or from the contrib directory of the official gnuplot ftp site (ftp://ftp.gnuplot.vt.edu/pub/gnuplot/contrib/(leave)) or mirrors. It might still be available from the old Gnuplot 3.6beta ftp site (/incoming/) (leave).

Kown problems:

8.7.1998 I found someone, who managed to compile fig2dev for MS-Windows machines. At least postscript output is possible. (In theory you could use ghostscript to get to raster-image formats like png.) On Norman Hendrich`s JavaFIG homepage(leave) you can also find a shareware software (unlimited trail period for non-commercial use) to edit fig files. Note: I have not tested the mentioned programs yet.

Use thick lines

25.6.2004 Andrew Tannenbaum (trb |a| theworld com) emailed me another nice workaround using thick lines:
# colored_bars.dem
set nokey
set yrange [0:10]
set xrange [0:6]
set grid
set xtics ('pm1' 1, 'pm2' 2, 'pm3' 3, 'pm4' 4, 'pm5' 5)
plot '<echo 1 1  2 5  3 3  4 9  5 7' \
      u 1:2 w imp lw 50, '' u 3:4 w imp lw 50, \
   '' u 5:6 w imp lw 50, '' u 7:8 w imp lw 50, \
   '' u 9:10 w imp lw 50
Depending on the output terminal you need, you should try if this solution actually works for you.

Patch gnuplot 3.7.x

This solution is quite usable for non-vector output formats. You have to apply the patch against the right version of gnuplot sources. (I only tested an older version of this hack.)
A bit of History
for gnuplot 3.7.0
gpl37fboxpatch.tar.gz(leave) Patch for gnuplot3.7. Negative Value bug should be fixed. The update was done by James Turck < jturck@hotmail.com > with help from Khilan Shah.
for gnuplot3.6pl336
A patch from Steve Cumming was updated for gnuplotv3.6 by sethg@eng.sun.com. You have to apply the patch to the old sources of the 3.6beta pl336 and recompile gnuplot. I have saved it from the gnuplot newsgroup and saved it for the gnuplot community. Get it from the contrib directory of gnuplot ftp site or mirrors. The files also might still be available from the old Gnuplot 3.6beta ftp site (/incoming/) (leave).
28.10.1997 Some people have reported difficulties compiling gnuplot with the patch. (But I am not aware of further information on this issue.)
7.7.1998 Added Link to Ian`s bugfix.
8.7.1998 Ian informed me, that he discovered a bug when ploting filled boxes with negative values.
14.4.1999James and Kihlan announced the new patch! Hurray!
4.11.1999Lars informed me of the updated patch.
25.6.2004Lars informed me of the updated patch.
«Gnuplot -- scientific plotting Internal | Infoservice last modified: June 2004
E-Mail: Bernhard.Reiter@usf.uni-osnabrueck.de

[ XFIG, FIG and associated software(leave) ] [ Piecharts with (GNU)plotutils(leave) ]