# Gnuplot inside LaTeX not working

I'm trying to create a gnuplot image inside my LaTeX document, but nothing is being displayed.

My gnuplot works if I do it outside LaTeX.

\begin{figure}[!ht]
\begin{gnuplot}[terminal=pdf, terminaloptions=color, scale=0.9]
set title 'Laptop Steps'
set datafile separator ','
set xlabel 'Query'
set ylabel 'Average time in ms(100 executions)'
set xrange [0:21]
set xtics 1,1,20
set logscale y
set grid ytics lt 0 lw 1 lc rgb '#bbbbbb'
set grid xtics lt 0 lw 1 lc rgb '#bbbbbb'
set key samplen 2 spacing .5 font ',8'
show grid
set style fill solid 0.8 border -1
set boxwidth 0.5 relative
plot for [i=1:14] 'benchmarks/basex-steps-laptop-transposed.csv' u (\$0+1):i title ''.i.'00 kb' with linespoints \end{gnuplot} \end{figure}  I'm using vim with the latex plugin. The structure of my project is: main |-chapters/the-file-with-the-gnuplot-code |-benchmarks/benchmark-file.csv  For gnuplot I have this in my document: \usepackage{gnuplottex} \usepackage{epstopdf}  I only get the warning: Package gnuplottex Warning: Please convert thesis-gnuplottex-fig1.gnuplot manually Does anyone have an idea what I'm doing wrong? • You must use -shell-escape when calling pdflatex, see the third sentence in the gnuplottex-documentation. And you don't need the epstopdf package if you're using the pdf terminal. – Christoph Dec 2 '13 at 10:45 • Hi! It seems to me that your question is very similar to this one: Gnuplot and PDFLatex question. Please have a look, and if the one I link above helps you, we can mark the questions as duplicates of each other. – yo' Dec 2 '13 at 10:46 • @Christoph I'm using -shell-escape, I should have written this into my question. – EarlOfEgo Dec 2 '13 at 10:59 ## 1 Answer If you run gnuplot <basename>-gnuplottex-fig1.gnuplot, you'll see gnuplot's error message plot for [i=1:14] 'benchmarks/test.csv' u (\$0+1):i title ''.i.'00    kb' with linespoints
^
"texse-gnuplottex-fig1.gnuplot", line 16: invalid character \


gnuplot is stumbling over the \$. You don't need to escape the dollar sign in a gnuplot environment. If you remove the backslash, everything should work. \documentclass{article} \usepackage{gnuplottex} \begin{document} \begin{figure}[!ht] \begin{gnuplot}[terminal=pdf, terminaloptions=color, scale=0.9] set title 'Laptop Steps' set datafile separator ',' set xlabel 'Query' set ylabel 'Average time in ms(100 executions)' set xrange [0:21] set xtics 1,1,20 set logscale y set grid ytics lt 0 lw 1 lc rgb '#bbbbbb' set grid xtics lt 0 lw 1 lc rgb '#bbbbbb' set key samplen 2 spacing .5 font ',8' show grid set style fill solid 0.8 border -1 set boxwidth 0.5 relative plot for [i=1:14] 'benchmarks/test.csv' u ($0+1):i title ''.i.'00    kb' with linespoints
set out
\end{gnuplot}
\end{figure}
\end{document}

• Very good catch! I think that the question title should be edited to include $, so that this is a good reference for other people. As well, my comment above about being a duplicate is obviously wrong. – yo' Dec 2 '13 at 10:49 • That's why I always recommend to use column(0) instead of $0 when calling gnuplot from another program/script. That avoids any escaping issues. – Christoph Dec 2 '13 at 10:50