1

I would like to make TikZ plots from Gnuplot or to make the Gnuplot more similar to the TikZ results (same fonts, lines and points).

I use this script

set xlabel "Time, t [s]" # font " Helvetica,16"
set ylabel "Batch identification probability, b(t)" # font "Helvetica,16"
load "estilos100.txt"
set key spacing 1.5

set key right bottom 
set xrange [0:2]
# set terminal latex
set terminal postscript enhanced color dashed
set key box
set out "bK16.eps"
plot 'FSAK16.dat' using 1:($9 == 0 ? NaN : ($9 == 1? NaN : $9)) title 'N=100, K=16' with lp ls 10,\
'FSAK16-ERRORES.dat' using 1:($9 == 0 ? NaN : ($9 == 1? NaN : $9)) title 'N=100, K=16, cap' with lp ls 11,\
'FSAK16-POISSON.dat' using 1:($9 == 0 ? NaN : ($9 == 1? NaN : $9)) title 'P(@^{\320}N=100), K=16' with lp ls 20,\
'FSAK16-POISSON-ERRORES.dat' using 1:($9 == 0 ? NaN : ($9 == 1? NaN : $9)) title 'P(@^{\320}N=100), K=16, cap' with lp ls 22

enter image description here

The data files have many rows and columns and are in this link.

EDIT

Following the comments, I have tried to plot using TikZ addplot as

\documentclass[border=1mm]{standalone}

\usepackage{tikz,pgfplots}

\begin{document}

\centering
\begin{tikzpicture}
    \begin{axis} [
        %width=21cm, height=14cm,
        % tick label style={font=\large},
        xmin=0, xmax=2,
       % xtick={7700,7725,...,7800},
        axis x line=box,
        axis y line=box
       ]

    \addplot gnuplot [raw gnuplot, id=test0, mark=none]{
    set xrange [0:2];
    %set yrange [0:0.05];
    % plot "test.txt" using ($1):($2) every 1:1:100500::105000 with lines;
    plot 'FSAK16.dat' using 1:($9 == 0 ? NaN : ($9 == 1? NaN : $9)) %title 'N=100, K=16' with lp ls 10 
    };

    \addplot gnuplot [raw gnuplot, id=test1, mark=none]{
    set xrange [0:2];
    plot 'FSAK16-ERRORES.dat' using 1:($9 == 0 ? NaN : ($9 == 1? NaN : $9)) %title 'N=100, K=16, cap' with lp ls 11 %,\
    };

    \end{axis}
\end{tikzpicture}
\end{document}

Which it plots the lines but not the points. How I could plot the lines and the points together?.

enter image description here

  • 2
    Welcome to TeX.SE. I would recommend you use gnuplot to generate the data and then pgfplots to produce the plot. – Peter Grill Aug 27 at 17:55
  • @PeterGrill Thank you. Do you know where I could find an example of the procedure?. I have tested the latex terminal with this plot and input the file in a latex doc but it does not work form me. – pablo Aug 27 at 18:10
  • There should be plenty of examples on this site. If you have data points, then it is just a matter of plotting points and no longer a gnuplot issue. – Peter Grill Aug 27 at 18:45
  • @PeterGrill Thank you I think I know how to get the figures. I only would like to ask you how to add the points to the lines as in the first figure. – pablo Aug 27 at 19:20
  • 1
    Using mark=none means that no mark is displayed. Try using mark=square* mark=*,and 'mark=triangle, etc. See p. 183 of the pgfplots manual. If this has solved your question, please post your solution as an answer as it may be helpful to others in the future. – Peter Grill Aug 27 at 20:53
2

Thanks to the comments I have generated easily the Gnuplot figure with TikZ. I have used gnuplot raw option o addplot as follows,

\documentclass[border=1mm]{standalone}
\usepackage{amsmath}
\usepackage{tikz,pgfplots}
\pgfplotsset{width=11cm,compat=1.15}

\begin{document}
\centering
\begin{tikzpicture}
    \begin{axis} [
        legend pos=south east,
        legend cell align={left},
        xlabel={Time, $t$\,[s]},
        ylabel={Batch identification probability, $b(t)$},
        axis x line=box,
        axis y line=box
       ]

    \addplot gnuplot [raw gnuplot, id=test, mark repeat=20, mark phase=0]{ % mark none for no points
    plot 'dat/FSAK16.dat' using 1:($9 == 0 ? NaN : ($9 == 1? NaN : $9))
    };
    \addlegendentry{$N$=100, $K$=16};

    \addplot gnuplot [raw gnuplot, id=test, mark repeat=10, mark phase=0]{
    plot 'dat/FSAK16-ERRORES.dat' using 1:($9 == 0 ? NaN : ($9 == 1? NaN : $9))
    };
    \addlegendentry{$N$=100, $K$=16, cap};

    \addplot gnuplot [raw gnuplot, id=test, mark repeat=40, mark phase=0]{
    plot 'dat/FSAK16-POISSON.dat' using 1:($9 == 0 ? NaN : ($9 == 1? NaN : $9))
    };
    \addlegendentry{P($\overline{N}$=100), $K$=16};

    \addplot gnuplot [raw gnuplot, id=test, mark repeat=20, mark phase=0]{
    plot 'dat/FSAK16-POISSON-ERRORES.dat' using 1:($9 == 0 ? NaN : ($9 == 1? NaN : $9))
    };
    \addlegendentry{P($\overline{N}$=100), $K$=16, cap};

    \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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