397946 (2) [Avatar] Offline
#1
Does anyone know how to make gnuplot's epscairo driver output BoundingBox and HiResBoundingBox that fit tightly around the drawn figure? By default, it appears to give only identical BoundingBox and PageBoundingBox that include a lot of white space around the figure. I've been using this two liner (in a script) to fix it:
gs -dNOPAUSE -sDEVICE=bbox -- THEFILE.eps 2> THEFILE.bbox >/dev/null
sed -e "/%%.*BoundingBox/r THEFILE.bbox" -e "/%%.*BoundingBox/d" < THEFILE.eps

However, it seems to me that it would be preferable for the gnuplot output to default to providing usable BoundingBox and HiResBoundingBox, or at least for that to be an option. (Note: Gunplot 5.0.5, MacOS)
philipp.janert (283) [Avatar] Offline
#2
Good question.

I am not aware of any setting that would allow you to manipulate the EPS bounding box individually using the epscairo terminal.
Like you, I tend to use external tools (such as ps2eps).

That being said, the canonical way to achieve the desired effect would be to use gnuplot's own facilities. Essentially:
set terminal ... size
to set the specific size of the resulting graph that you want, and
set margin ...
to remove the gratuitous whitespace around the graph. Also don't
forget
set size ...
to control the size of the graph itself.

One problem with "tight bounding boxes" is that you don't know ahead of time how large your final figure really will be.
By contrast, gnuplot's approach is that it gives you a canvas (!) of exactly the size specified in the "set terminal ..." command,
but that the size of the graph on that canvas is controlled independently using "set size" and "set margin".
397946 (2) [Avatar] Offline
#3
That's an interesting approach. I may try it, if I want my figure to be a certain size. However, I usually don't care much about the exact size and shape, I just want to get rid of the excess white space in a general way.

Also, thanks for the reminder about ps2eps.