# Use GnuPlot with latex

I wanted to plot a graph with log base 2 using my data on latex. It plots a straight line while it should have ploted a curve .

    \begin{gnuplot}[terminal = latex, terminaloptions = {size 2.8in,3.0in}]
set mxtics 2
set mytics 2

set key left top

set xrange[1.0:0]
set yrange[1.6:1.62]
set xlabel "User selected parameter $t_0$"
set ylabel "\\rotatebox{90}{Validation Error (\\%)}"

plot "data" u 1:(log(5)) with linespoint lc "black" title "abc"


Can anyone assist me with this? I am plotting this on Overleaf.

• pgfplots and tikz allow you to use gnuplot. Of course, to plot a straight line, you do not need gnuplot. – user121799 Oct 1 '18 at 18:28
• @marmot I manually converted the data. It should have plotted a curve. Not sure whats happening – Sohil Oct 1 '18 at 18:42

You probably meant to write u 1:(log($5)) (note the $).

\documentclass{article}
\usepackage{gnuplottex}

\begin{document}

\begin{gnuplot}[terminal = latex, terminaloptions = {size 2.8in,3.0in}]
set mxtics 2
set mytics 2

set key left top

set xrange[1.0:0]
set yrange[1.6:1.62]
set xlabel "User selected parameter $t_0$"
set ylabel "\\rotatebox{90}{Validation Error (\\%)}"

plot "data.dat" u 1:(log(\$5)) with linespoint lc "black" title "abc"
\end{gnuplot}

\end{document}


Here is my made-up data.dat.

0.0 0 0 0 5.00
0.1 0 0 0 5.01
0.2 0 0 0 5.02
0.3 0 0 0 5.03
0.4 0 0 0 5.02
0.5 0 0 0 5.01
0.6 0 0 0 5.00
0.7 0 0 0 5.01
0.8 0 0 0 5.02
0.9 0 0 0 5.03
1.0 0 0 0 5.02


Live example on Overleaf