[Tex/LaTex] Use GnuPlot with latex

gnuplotgnuplottexoverleaf

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.

Best Answer

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

Related Question