1
votes

I am plotting graphs in gnuplot with epslatex terminal. Here is my .plt script :

set terminal epslatex size 2.5,2.5 color blacktext
set output 'xxx.tex'
set format x '$10^{%T}$'
set format y '${%1.1t}^{*}10^{%T}$'
set ytics add ('0' 0)
set xlabel "xxx"
set ylabel "xxx"
set logscale x
set key below
plot    "xxx.dat" using 1:2 title 'xxx' pt 4 ps 2 lc 1
set output

And here is my .tex file where it is embedded :

\documentclass[10pt]{article}
\usepackage[pdftex]{graphicx}
\usepackage{epstopdf}
\usepackage[cp1252]{inputenc}
\usepackage{color}
\begin{document}

\begin{figure}[h!]
\fontsize{6}{2}\selectfont
\input{xxx.tex}
\end{figure}

The resulting graph is fine, but with additional white space due to the reduced font size : plot

  • I tried the command "ylabel offset", but it just moves the white space to the left and does not resize the actual plot.

  • I also tried lmargin, but then the ylabel exits the figure space.

  • Putting \footnotesize in ylabel gave a worst result (ytics were poorly placed above y axis).

Would anyone have any tips on how to set the white space to a minimal value and optimize the plot? Ideally, it would be a command to set the spacing between ytics and ylabel to a fixed value...

Thank you

1
I would make lmargin smaller so that the is less space to the left of the y-axis, and then use ylabel offset to move the y axis label to the right.user8153
Gnuplot doesn't know, that you're reducing the font size later, so that all offsets (tics and labels) are too large. Try terminal epslatex standalone font ",6"Christoph
@user8153 thanks for the tiplovegnuplot
@Christoph Thanks very much, this is exactly what I was looking forlovegnuplot

1 Answers

2
votes

The epslatex terminal will create enough whitespace around (offset) the axes or wherever there is text to make sure there is sufficient room to typeset the text when you include the output .tex document in your master document. It bases the amount of white space off the font size you specify in the epslatex terminal command:

set terminal epslatex size 2.5,2.5 color blacktext

If you set the font size to what you're planning on using in your document it should calculate the appropriate amount of white space. You just need to include a font ",6pt" argument to your set terminal line:

set terminal epslatex font ",6pt" size 2.5,2.5 color blacktext

That should work.

As an aside you can include extra latex commands in your output .tex with the header argument. That was you don'e need to include them when you \input your gnuplot output:

set terminal epslatex font ",6pt" size 2.5,2.5 color blacktext header "\\fontsize{6}{2}\\selectfont"

Note that back slashes need to be escaped with a backslash. You can chuck all sorts of stuff in there. I often make my figure and graph text sans-serif so I use something like:

set terminal epslatex font ",9pt" round\
    size 10.5cm,9cm \
    header "\\sffamily"