# Plot command in TikZ not working [closed]

I just can't make the command plot in TikZ work. For example, even such basic code as

\documentclass{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[domain=0:4]
\draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
\draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};
\draw[->] (0,-1.2) -- (0,4.2) node[above] {$y$};
\draw[color=red]   plot (\x,{\x})   node[right] {$f(x)=x$};
\end{tikzpicture}

\end{document}


produces this error, with no PDF output:

ERROR: Package tikz Error: Cannot parse this plotting data.


If it can be of any help, in the .log file I found this message:

Missing character: There is no , in font nullfont!
! Undefined control sequence.
l.11     \draw[color=red]   plot (\x,{\x
})   node[right] {$f(x) =x$};


If I comment out the line containing the plot command, things compile nicely.

Interestingly, if I include \usepackage{pgfplots} in the preamble, then I get a different error message in ltluatex.tex:

ERROR: Undefined control sequence.

--- TeX said ---
l.55 \ifnum\luatexversion
<60 %


Btw, I am running TeX Live 2017 on a MacBook Pro. Any help would be greatly appreciated.

UPDATE: Following @Torbjørn T.'s suggestion, I have removed the old version of TikZ from my local tree. While plot is still not working, at least the error message has changed. Now it's:

ERROR: Undefined control sequence.

--- TeX said ---
l.533 \pgfset
{


The error refers me to the file pgfmoduleshapes.code.tex (2008/02/13 (rcs-revision 1.4)). Thanks in advance.

## closed as off-topic by user156344, Stefan Pinnow, Raaja, Mensch, TeXnicianMar 3 at 11:42

• This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

• You should to add in your question about problem compilation only with lualatex. With pdflatex there is no problem. – sergiokapone Feb 10 '18 at 18:48
• luatex probably still needs \RequirePackage{luatex85} but beside this your code compiles fine and doesn't give your error message. Can you show the log-file? – Ulrike Fischer Feb 10 '18 at 18:56
• It is possible, the conflict between lualatex with standalone – sergiokapone Feb 10 '18 at 19:02
• \RequirePackage{luatex85} goes before \documentclass. Your code works fine here as well, with either lualatex, xelatex or pdflatex. – Torbjørn T. Feb 10 '18 at 19:23
• I'm voting to close this question as off-topic because the OP solved the problem himself and posted the solution in a comment. – user156344 Mar 3 at 8:46