Open Pitigrilli opened 1 year ago
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}
\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
https://github.com/pgf-tikz/pgfplots/blob/9f4e2b14af77fd196d769e98dbc622d68dd8df88/tex/generic/pgfplots/pgfplots.code.tex#L4681-L4685
Setting \pgfplotsset{compat=1.18, lua backend=false}
works too (by hiding the problem).
The root cause has been reported to pgf
in https://github.com/pgf-tikz/pgf/issues/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 https://github.com/pgf-tikz/pgf/issues/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}
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.
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.