I'm trying to generate a scatterplot from points produced by a lua function.
I've simplified this into the following mwe, based on https://tex.stackexchange.com/a/77864/9454:
\documentclass{article}
\usepackage{luacode}
\usepackage{tikz,pgfplots}
\begin{luacode*}
function test()
tex.print([[1 4.3 a]])
tex.print([[2 5.1 a]])
tex.print([[3 5.7 a]])
tex.print([[4 6.3 a]])
tex.print([[5 6.8 a]])
tex.print([[6 7.1 a]])
tex.print([[7 7.2 a]])
tex.print([[8 7.2 a]])
tex.print([[9 7.2 a]])
tex.print([[10 7.2 a]])
tex.print([[11 7.5 a]])
tex.print([[12 7.8 a]])
end
\end{luacode*}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
scatter/classes={%
a={mark=o,draw=black}}]
\addplot[scatter,only marks,%
scatter src=explicit symbolic]%
table[meta=label] {
x y label
\directlua{test()}
};
\end{axis}
\end{tikzpicture}
\end{document}
But instead of the scatter plot, I get:
Package pgfplots Error: Sorry, the requested column number '1' in table '<inline_table>' does not exist!? Please verify you used the correct index 0 <= i < N.
I've tried messing with \pgfplotstableread
but I could not get that to work either.
How can I pass the data from test()
to the scatter plot?
io
which I then load the data in from pgfplots, but that's not very sastisfying