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

Regression? Incorrect rendering on LuaTeX with compat set to 1.12 or later #492

Closed
cfr42 opened this issue Sep 12, 2024 · 7 comments · Fixed by pgf-tikz/pgf#1359
Closed

Comments

@cfr42
Copy link

cfr42 commented Sep 12, 2024

Ref. https://tex.stackexchange.com/q/726281/ and https://tex.stackexchange.com/a/726304/

The example from Jasper's question renders incorrectly if compiled with LuaTeX if compat=1.18. Experimentation shows the cutoff is between 1.11 and 1.12 as demonstrated by the example below. Compiled as-is, the image is only partially rendered. If the current compat line is commented and the one below uncommented, the output is correct.

This appears to be engine-specific as the regression does not affect pdfTeX. compat=1.18 renders the image completely on this engine.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
% \pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[%
      enlargelimits = true,
      axis lines = none, ticks = none,
      cyl/.style = {%
        surf,
        black!30!,
        variable = \u,
        variable y = \v,
        z buffer = sort,
        faceted color=black!70!,
      },
    ]

    \addplot3[%         (-) Z-SEMIAXIS
      cyl,
      domain = -3:3,
      y domain = 0:360,
    ] ({cos(v)}, {sin(v)}, {min(u,abs(cos(v)),abs(sin(v)))});

    \addplot3[%         (-) X-SEMIAXIS
      cyl,
      domain = -3:3,
      y domain = 0:360,
    ] ({min(u,-abs(cos(v)),-abs(sin(v)))}, {cos(v)}, {sin(v)});

    \addplot3[%         (+) Y-SEMIAXIS
      cyl,
      domain = 0:360,
      y domain = -3:3,
    ] ({cos(u)}, {max(v,abs(cos(u)),abs(sin(u)))}, {sin(u)});

    \addplot3[%         (+) X-SEMIAXIS
      cyl,
      domain = -3:3,
      y domain = 0:360,
    ] ({max(u,abs(cos(v)),abs(sin(v)))}, {cos(v)}, {sin(v)});

    \addplot3[%         (+) X-SEMIAXIS
      cyl,
      domain = -3:3,
      y domain = 0:360,
    ] ({cos(v)}, {sin(v)}, {max(u,abs(cos(v)),abs(sin(v)))});

    \addplot3[%         (-) Y-SEMIAXIS
      cyl,
      domain = 0:360,
      y domain = -3:3,
    ] ({cos(u)}, {min(-abs(cos(u)),-abs(sin(u)),v)}, {sin(u)});

  \end{axis}
\end{tikzpicture}
\end{document}
@Mo-Gul
Copy link
Contributor

Mo-Gul commented Sep 12, 2024

The problem seems to be that the Lua functions min and max do only handle the first two arguments, see

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        domain=0:3,
        samples=4,
    ]
        \addplot {min(1,x)};
        \addplot {min(1,2,x)};
%        \addplot {min(1,min(2,x))};     % <-- workaround

%        \addplot {max(2,x)};
%        \addplot {max(1,2,x)};
    \end{axis}
\end{tikzpicture}
\end{document}

grafik

(I did not test other functions that might show the current bug.)

@cfr42
Copy link
Author

cfr42 commented Sep 13, 2024

So what changed in 1.12? Did pgfplots or pgf switch to using the Lua functions?

@hmenke
Copy link
Member

hmenke commented Sep 13, 2024

image

@cfr42
Copy link
Author

cfr42 commented Sep 17, 2024

Sorry. I don't use pgfplots very much and I probably shouldn't be submitting anything on GitHub. But does that mean the bug is in the lua backend and should be reported elsewhere, that it isn't considered a bug or neither?

@hmenke
Copy link
Member

hmenke commented Sep 17, 2024

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
% Workaround for https://github.com/pgf-tikz/pgfplots/issues/492
\directlua{
  pgfluamathfunctions.stringToFunctionMap["max"] = math.max
  pgfluamathfunctions.stringToFunctionMap["min"] = math.min
}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[domain=0:3, samples=4]
    \addplot {min(1,x)};
    \addplot {min(1,2,x)};
  \end{axis}
\end{tikzpicture}
\end{document}

@Mo-Gul
Copy link
Contributor

Mo-Gul commented Sep 17, 2024

Awesome. Your (@hmenke) workaround as well as the fix work perfectly fine.

@cfr42
Copy link
Author

cfr42 commented Sep 18, 2024

Thank you for fixing this so rapidly.

hansonchar pushed a commit to hansonchar/pgf that referenced this issue Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants