Summary: Is there a way to automatically reduce the bounding box of an eps file to only fit displayed text?
Details:
A while ago I asked a question about combining multiple gnuplot graphs into a single figure. I am trying to do something similar, but this time I also want to only have one legend for all the figures. To accomplish this I want to generate a graph with only the legend, and then place that in the appropriate place in the figure as a subfigure.
I am able to generate a gnuplot with only the legend by turning off everything else and setting the plot range to a section that does not display any data using these commands:
unset border
unset xtics
unset ytics
unset title
unset xlabel
unset ylabel
set xrange[-50:-10]
set yrange[-50:-10]
This gives me a graph with only the key set. The problem is that the bounding box still contains the space for the actual graph (shown below). What I would like to do is crop this to something that only contains the key so that I can combine that easily with the other plots (as described in the answer to my other question).
I am able to get something closer to what I want by manually editing the bounding box, but I would prefer a fully scripted solution if possible. I've tried a few things but haven't gotten it working yet so I thought I would ask here since my earlier question received a very helpful answer.
Initial eps file:
Desired eps file (after editing bounding box):
pdfcrop
tool, convert it back from PDF to EPS. Or try GhostScript and use thebbox
device?pdfcrop
does what I need.