Boxfill.pl is a perlscript for filling (and outlining) boxes in 
postscript files produced with gnuplot. Boxes and keys are filled with 
the color used by gnuplot for outlining the boxes. Boxes and keys are 
outlined (if option -o is selected) with the linestyle used by gnuplot 
for the borders and the tics. The script is in a horrible beta stage and 
might produce unpredictable output, but works for all my needs I 
encountered up to now and so perhaps there is somebody out there it 
might help. The script is only tested with some files produced by 
gnuplot 3.7 patchlevel 1, I don't know whether it also works with other 
gnuplot versions. It's also not tested on non-unix platforms, you have 
to adjust at least the first line where the position of perl on your 
system is defined.

The script needs at least two arguments, a postscript file produced by 
gnuplot and an output file. Input and output file can be the same, but 
be aware, if you manually changed the input file, your changings are 
lost if the output is not as expected. Other options are explained in 
the "known problems" section.

The size of the keys can be manipulated by changing the values for "vpt" 
in the postscript code or if you don't want that (e.g., because you also 
plot with points in the same graph) the same can be done by adding the 
command "<multiplier> UP" (e.g., 2 UP) in the postscript code somewhere 
near before the key is drawn.

The example files show how boxfill.pl is expected to work. Run 
example.sh and a set of postscript files is produced. Have a look at 
them and try experimenting with your own gnuplot scripts.


KNOWN PROBLEMS AND RESTRICTIONS:

- The script works by searching for a series of four rmoveto-commands in 
the postscript file and replacing them in a manner that the resulting 
boxes are filled (and outlined). However, these sequences may not be 
unique to boxes in the postscript file. The only case in which I 
encountered this problem was in multiplot mode, for the second and the 
subsequent frames. This problem is solved in the way that boxes are not 
filled, if they directly follow the define linetype command used by 
gnuplot by default (lt -1) for the frames. Thus, what definitly won't 
work is a linetype for the borders different from -1 in multiplot mode. 
What also doesn't work are boxes drawn in lt -1 without having a 
key/title (i.e., with the notitle option).

- The second problem with this approach is that not all boxes are drawn 
by such a sequence. This is true for boxes with a height of zero. This 
is only a problem in outline mode when instead of a colored line a black 
line should appear. Use the -z option in this case, but only if you 
really need it, it's still experimental.
If it plots functions gnuplot sometimes uses a different sequence of 
commands (see example 5), I couldn't find the regularity yet. something 
that might help, is using the commented out $box variable marked as 
experimental and commenting out the default one, as it works for example 
5 (you have to get into the source code to change that).

- Sometimes gnuplot inserts a postscript command ("currentpoint stroke 
M") in the sequence. This command is not really needed and prevents 
correct detection of boxes. If you encounter a single unfilled box in a 
series of filled boxes and you don't know why, try using the -r option 
which fixes that, but be careful this may remove the command also from 
locations where it's necessary, even though I didn't find such a case 
yet (see examples 4 and 5).

- The key is not detected and drawn properly if the first box is of zero 
height or irregular command structure. Exchanging the experimental $key 
variable in the code as described above for $box might help, but only do 
so if needed, it's still experimental (see example 4).

- The linetype for the outlines can be changed by setting a different 
value for the variable $outlinestyle in the perl script (possible 
values: LTb, LTa and LT0 to 9). However, all boxes are outlined with the 
same linetype. If you need different outlinestyles for different records 
you have to adjust this manually in the postscript code.

- The postscript code used is not really staight forward and clean. It 
works well with ghostscript and all postscript printers I could test, 
but there may also exist interpreters getting in trouble with the code.


I'm absolutly sure that there is a whole bunch of more bugs and 
restrictions I didn't find. Feel free to report them to me 
(widmann@rz.uni- leipzig.de). But please do not rely on a fast bugfix, I 
only can do that if there is time aside from work. I always appreciate 
to hear comments and whether the script was useful.
