# use shell-escape output with newlines in pgfplots/tikz

The following example works:

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
0 0
0.5 0.25
1 1
};
\end{axis}
\end{tikzpicture}
\end{document}


However, I cannot take the data from an external program. As a simulation let us say that

printf '0 0\n0.5 0.25\n1 1\n'


prints the desired

0 0
0.5 0.25
1 1


Now I would like to write instead

\addplot table{
\input|"printf '0 0\n0.5 0.25\n1 1'"
};


and compile it with pdflatex --shell-escape. I am quite sure that the newlines are the problem and catcode tables may be a solution but I was not able to find an appropriate solution.

Update: \string\n and expandable input via @@\input were suggested similar to something like:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\makeatletter
\let\zz\@@input
\makeatother
\begin{document}
\begin{tikzpicture}
\begin{axis}
\zz|"printf '0 0\string\n0.5 0.25\string\n1 1'"
};
\end{axis}
\end{tikzpicture}
\end{document}


I think, I have tried all variations with \zz,\input,\n, \string\n, \string\n\string\n and none of them worked.

• probably you want \string\n but it depends on whether you need another layer of quoting for the \  on your command shell, it is system dependent, but you need \string\n or it tries to expand the undefined tex command \n, but it could be you need \string\\n instead:-) – David Carlisle May 3 '18 at 19:07
• Your suggestion works outside a tikzpicture but unfortunately not inside a tikzpicture. (Doubling \string\ndid not work either, inputting with an expandable input did not work either.) – Linus Romer May 3 '18 at 19:43
• can you use a normal file input at that point or does the argument of \addplot table need to expand to its content (in which case you would need \@@input not \input (and make @ a letter with \makeatletter ) – David Carlisle May 3 '18 at 20:02
• I would like to solve this problem without needing to write and read an extra file. I have updated the question (\@@input did not yet solve the problem). – Linus Romer May 3 '18 at 20:26

According to Christian Feuersänger (the author of pgfplots), everything inside addplot{}` is not expandable. Hence, a solution with the given conditions is not possible.