1

I'm using gnuplot with terminal epslatex in order to plot graphs containing LaTeX labels.

In particular I've got something like this on Y tics:

$\\frac{ L_{seq} }{ 8 }$

Everything works, but the output graph has a lot of white space between the Y axis label and the Y tics.

I guess that's because gnuplot parses $\\frac{ L_{seq} }{ 8 }$ as a normal string and reserves space for it, but the resulting string (after pdflatex renders it) will actually be shorter.

Any way to solve this?

3
  • 2
    There are much more elegant ways of getting datasets plotted. Take a look at »pgfplots« or »pst-plot«. Dec 8, 2010 at 17:05
  • @Martin: Is the double backslash really correct? Feb 7, 2011 at 17:47
  • 1
    @Hendrik: Yes, the backslash needs to be escaped in Gnuplot.
    – Jake
    Feb 7, 2011 at 18:01

3 Answers 3

3

In my experience it's best to let graphics programs such as gnuplot use their own (non LaTeX) labels, and then replace these using psfrag. psfrag allows you to align the left/right/centre of the object to be replaced with the left/right/centre of the replacement. So, in gnuplot try

set term postscript eps mono
set output 'myplot.eps'
set ylabel 'Y'
plot x**3

and then in your document

\usepackage{psfrag}

...

\psfrag{Y}[r][r]{$y=x^3$}
\includegraphics{myplot}
1

Use next code to make two tics on Y axis. It works correctly.

set label "$U_{in}$" right at graph 0, first 3.4 offset character -1,0
set ytics add ("" 3.4)
set ytics add ("" 3.4/sqrt(2))
set label "$\\frac{U_{in}}{\\sqrt{2}}$"right  at graph 0, first 3.4/sqrt(2) offset character -1,0
0

This answer is not directly related to LaTeX, rather it's an ugly workaround from the gnuplot's side. When I used epslatex terminal of gnuplot and I had this problem I "solved" adding an offset to the axis label like this:

set ylabel 'axis label' offset 2,0

where the x offset (the number 2 in the example) is found by trial and error.

(As already noticed in a comment, there are more elegant alternatives to include plots in (La)TeX documents: personally I've switched to pgfplots.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .