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

comma as decimal separator in table doesn't work with lua backend. #452

Open
Pitigrilli opened this issue Jan 24, 2023 · 3 comments
Open

Comments

@Pitigrilli
Copy link

Compiling the following example with lualatex
(This is LuaHBTeX, Version 1.15.0 (TeX Live 2022) (format=lualatex 2023.1.23) 24 JAN 2023 18:08) )
results in an empty diagram.

Warning in the log-file:
NOTE: coordinate (--,--,--) [--](was (1,2,0,9,--) [--]) has been dropped because of a coordinate filter.

\documentclass[]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}  % works only with pdflatex from compat=1.12 to 1.18
%\pgfplotsset{compat=1.11} % works with lualatex
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot table [
	x = x,
	y = y,
	/pgf/number format/read comma as period
] { 
	x 	y
	1,2 0,9
};
\end{axis}
\end{tikzpicture}
\end{document}
@dbitouze
Copy link

dbitouze commented Jun 7, 2023

It's worth pointing out that the issue doesn't arise with tikz's datavisualization library: the following MCE compiles like a charm with lualatex (LuaHBTeX, Version 1.17.0 (TeX Live 2023)).

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{datavisualization}
\begin{document}

\begin{tikzpicture}
\datavisualization [school book axes, visualize as line]
data [separator=\space] {
x y
0.5 0
1.5 1
2.5 1
3.5 0
};
\end{tikzpicture}

\pgfset{/pgf/number format/read comma as period}

\begin{tikzpicture}
\datavisualization [school book axes, visualize as line]
data [separator=\space] {
x y
0,5 0
1,5 1
2,5 1
3,5 0
};
\end{tikzpicture}
\end{document}

@muzimuzhi
Copy link
Member

\pgfplotsset{compat=1.18}  % works only with pdflatex from compat=1.12 to 1.18
%\pgfplotsset{compat=1.11} % works with lualatex

That's because lua backend is used by default since 1.12

/pgfplots/compat/general/1.12/.style= {
/pgfplots/compat/general/1.11,
/pgfplots/lua backend,
/pgfplots/compat/library hook={statistics}{/pgfplots/boxplot/estimator=Excel,/pgfplots/boxplot/ensure mark=true},
},%

Setting \pgfplotsset{compat=1.18, lua backend=false} works too (by hiding the problem).

@muzimuzhi
Copy link
Member

muzimuzhi commented Jun 7, 2023

The root cause has been reported to pgf in pgf-tikz/pgf#1263.

@dbitouze (in response to your comment in tex-sx) The problem is not uncovered in tikz examples because it's only pgfplots that turns on fpu and the un-documented library luamath under LuaTeX by default inside axis environment. In general tikzpicture doesn't even live with turned-on fpu, see pgf-tikz/pgf#678.

For a very specific (hence maybe highly limited) workaround, try the patch to \pgfplots@LUA@survey@point below

% !TeX program = lualatex
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\makeatletter
\def\pgfplots@LUA@survey@point{%
  \ifpgfmathparsenumber@comma@as@period
    % Assume each point is a single number without any math function calls. 
    % Only then is reading comma as period unambiguous.
    \edef\pgfplots@loc@TMPa{pgfplots.texSurveyPoint(%
      gsub("\pgfplots@current@point@x", ",", "."),%
      gsub("\pgfplots@current@point@y", ",", "."),%
      gsub("\pgfplots@current@point@z", ",", "."),%
      "\pgfplots@current@point@meta")}%
    \pgfplotsutil@directlua{%
      gsub = string.gsub
      \pgfplots@loc@TMPa
    }%
  \else
    \edef\pgfplots@loc@TMPa{pgfplots.texSurveyPoint(%
      "\pgfplots@current@point@x",%
      "\pgfplots@current@point@y",%
      "\pgfplots@current@point@z",%
      "\pgfplots@current@point@meta")}%
    \pgfplotsutil@directlua{\pgfplots@loc@TMPa}%
  \fi
  % increase \pgfplots@current@point@coordindex:
  \advance\c@pgfplots@coordindex by1
}%
\makeatother

\begin{document}
\begin{tikzpicture}
  \begin{axis}
    \addplot table [
      x = x,
      y = y,
      /pgf/number format/read comma as period
    ] { 
      x   y
      1,2 0,9
      1,4 1,3
    };
  \end{axis}
\end{tikzpicture}
\end{document}

image

Update: An answer to question https://tex.stackexchange.com/q/687857 is added, though I'm a little resistant to posting experimental patch to different places. Hope it provides some more (user-friendly?) info.

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

3 participants