The following example works:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot table{
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}
\addplot table{
\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.
\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:-)\string\n
did not work either, inputting with an expandable input did not work either.)\addplot table
need to expand to its content (in which case you would need ``\@@input` not\input
(and make @ a letter with \makeatletter )\@@input
did not yet solve the problem).