Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take data directly in Lua #493

Open
gerion0 opened this issue Sep 28, 2024 · 0 comments
Open

Take data directly in Lua #493

gerion0 opened this issue Sep 28, 2024 · 0 comments

Comments

@gerion0
Copy link

gerion0 commented Sep 28, 2024

I want to draw a box plot with pgfplots and in the documentation is mentioned that calculating the data with Lua is much faster than with TeX. Additionally, my data are already present in form of Lua tables.

My question now is: Is it possible to get the Lua data directly into pgfplots without the indirection over TeX?
I searched online for something similar and only found https://tex.stackexchange.com/questions/676821/pgf-scatterplot-table-from-lua which is more less exactly the way, I don't want to go. The data here is printed with Lua as TeX code, then parsed back into Lua code within pgfplots.

Ideally, I would expect some kind of data specification in pgfplots for Lua data and then be able to provide a global value name of some Lua table that pgfplots then uses as data source.

I mean something like this pseudo code, based on the above example:

\documentclass{article}
\usepackage{luacode}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18} 

\begin{luacode*}
userdata = userdata or {}
userdata.pgftable = {
    {}"x", "y", "label"},
    {1, 4.3, "a"},
    {2, 5.1, "a"},
    {3, 5.7, "a"},
    {4, 6.3, "a"},
    {5, 6.8, "a"},
    {6, 7.1, "a"},
    {7, 7.2, "a"},
    {8, 7.2, "a"},
    {9, 7.2, "a"},
    {10, 7.2, "a"},
    {11, 7.5, "a"},
    {12, 7.8, "a"},
}
\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, as_lua=on] {userdata.pgftable};
\end{axis}
\end{tikzpicture}

\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant