It depends on what you want to do.
AFAIK (I'm not an expert on gnuplot internals) gnuplot conveys most of how the plot is actually plotted on the terminal. This way, xrange and yrange will be able to give you a little more on both sides, but how much space actually (exactly) will depend on the size of the graph (so it will be different for png, small to png large - for example).
If you want to precisely control the size, then I think you need to work directly with a specific terminal, and not with gnuplot. However, Gnuplot supports a wide range of terminals. For this task, it is probably easiest to work with the metapost mp terminal. This allows you to reposition the border and ticks accurately.
To get this working you need a script
set term mp latex set output "xrange_example.mp" set view map set dgrid3d 2,2 splot "-" with points title "Data" 0 0 1 0 1 2 1 0 3 1 1 4 e set output set term pop
And your latex document (suppose you use this)
\documentclass{scrartcl} \usepackage{emp,ifpdf} \ifpdf \DeclareGraphicsRule{*}{mps}{*}{} \fi \begin{document} \includegraphics{xrange_example.0} \end{document}
Then you create your image using
> TEX=latex > gnuplot your_gnuplot.gp > mpost xrange_example.mp > pdflatex xrange.tex
This is the xrange_example.mp file that you are modifying. If you open it, you will find (about halfway down)
beginfig(0); w:=5.000in;h:=3.000in; a:=w/1200.0;b:=h/720.0;
a and b define scaling in width and height. After that add
numeric x[], y[]; x[0] = -10pt; x[1] = 10pt; y[0] = -10pt; y[1] = 10pt;
They enter the distances that you are going to add to the border and ticks. Ticks are defined like this
draw (193.0a,591.2b)--(193.0a,569.6b); % On the left draw (355.8a,165.4b)--(355.8a,187.0b); % on the right put_text( btex 0.2 etex, 355.8a, 117.8b, 0, 2); % the text
You want to change them like this:
draw (193.0a+x[0],591.2b)--(193.0a+x[0],569.6b); % On the left draw (355.8a+x[1],165.4b)--(355.8a+x[1],187.0b); % on the right put_text( btex 0.2 etex, 355.8a+x[0], 117.8b, 0, 2); % the text
As you can see, this is easy to do with search and replace (or in a script), because you only change the numbers 193.0a, 355.8a.
You need to do the same for xtics and borders
draw (192.9a,591.2b)--(192.9a,165.3b)--(1007.0a,165.3b)--(1007.0a,591.2b)--(192.9a,591.2b);
In general, I think you need to change 8 numbers (many times - very scripted).
As an example, I include a PDF plot sin(x) with a modified border. The border has been changed to exactly 10pt . (you can also choose this in mm or cm or inches, etc.)
