Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
2  
There are much more elegant ways of getting datasets plotted. Take a look at »pgfplots« or »pst-plot«. –  Thorsten Donig Dec 8 '10 at 17:05
    
@Martin: Is the double backslash really correct? –  Hendrik Vogt Feb 7 '11 at 17:47
    
@Hendrik: Yes, the backslash needs to be escaped in Gnuplot. –  Jake Feb 7 '11 at 18:01
add comment

3 Answers

up vote 2 down vote accepted

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}
share|improve this answer
add comment

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
share|improve this answer
add comment

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.)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.