[Tex/LaTex] raw gnuplot in pgfplots

gnuplotpgfplotsshell-escapetikz-pgf

I have a problem with the gnuplot environment in pgfplots. I already set "–enable-write18" in the argument of pdfLaTeX and added the path of gnuplot.exe to the PATH-variable in the advanced system options.

My problem now is that I can pass code in gnuplot (see picture), below are the 3 lines which I can't pass in the raw-gnuplot-environment in the tikzpicture (see code). What do I wrong? Can someone help, please?

pdfLaTeX-code:

\documentclass[a4paper]{scrartcl}

\usepackage[paperwidth=27cm,paperheight=17cm,margin=0in,showframe]{geometry}

\usepackage{tikz,pgfplots}


\begin{document}



\centering
\begin{tikzpicture}
    \begin{axis} [width=21cm, height=14cm,
    tick label style={font=\large},
    xmin=7700, xmax=7810,
    ymin=0, ymax=0.05,
    axis x line=box,
    axis y line=box
    ]
    \addplot gnuplot [raw gnuplot, id=test, mark=none]{
    set xrange [7700:7810];
    set yrange [0:0.05];
    plot "test.txt" using ($1):($2) with lines;
    };

    \end{axis}
\end{tikzpicture}



\end{document}

gnuplot-picture:
gnuplot, works

and finally my data-file:
http://www.file-upload.net/download-7764417/test.txt.html

Thank you in advance for your answer!

Best Answer

You don't tell us what error you're experiencing, so I can only guess at a possible solution: The problem is that, even though you restrict the plot range in gnuplot to x=7700:7810, gnuplot actually writes all the data entries into its output table. It merely marks the points outside the range using an o in the last column. PGFPlots then chokes on the huge amount of data it has to process (150000 points).

What you can do to work around your problem is to use the using syntax in gnuplot to process only a subset of the data. If you say

plot "test.txt" using ($1):($2) every 1:1:100500::105000 with lines;

gnuplot will process all the points starting with the the first block (there's only one block in your data), starting with line 100500, continuing until the last block, ending at line 105000. This range happens to include the values within your desired x range:

\documentclass[border=5mm]{standalone}

\usepackage{tikz,pgfplots}


\begin{document}

\centering
\begin{tikzpicture}
    \begin{axis} [width=21cm, height=14cm,
    tick label style={font=\large},
    xmin=7700, xmax=7810,
    xtick={7700,7725,...,7800},
    axis x line=box,
    axis y line=box
    ]
    \addplot gnuplot [raw gnuplot, id=test, mark=none]{
    set xrange [7700:7810];
    set yrange [0:0.05];
    plot "test.txt" using ($1):($2) every 1:1:100500::105000 with lines;
    };

    \end{axis}
\end{tikzpicture}



\end{document}
Related Question