# TikZ exits with “do not know the key '/tikz/restrict y to domain”

When I try to compile, I get the following error.

Runaway argument?
samples=60, domain=0:10, xmax=10.5, restrict y to domain=0:10, axis l\ETC.
! Paragraph ended before \pgfplots@@environment@axis was complete.
\par


with the input

\begin{tikzpicture}
\begin{axis}[samples=60,
domain=0:10, xmax=10.5,
restrict y to domain=0:10,
axis lines=left,
y=0.5cm/3,
x=0.5cm,
grid=both,
xtick={0,...,10},
ytick={0,3,...,9},
xlabel=$x$, xlabel style={at={(1,0)}, anchor=west},
ylabel=$y$, ylabel style={rotate=-90,at={(0,1)}, anchor=south}

]
\end{axis}
\end{tikzpicture}


Not working. Error is

! Package pgfkeys Error: I do not know the key '/tikz/restrict y to domain' and
I am going to ignore it. Perhaps you misspelled it.

See the pgfkeys package documentation for explanation.
Type  H <return>  for immediate help.
...

l.32 \end{axis}

?


with the MWE

\documentclass{article}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{epsf,graphicx,tikz,graphics}
\usepackage{pgfplots}
\usepackage{url}
\begin{document}
\title{}
\author{}
\maketitle
\begin{tikzpicture}
\begin{axis}[samples=60,
domain=0:10, xmax=10.5,
restrict y to domain=0:10,
axis lines=left,
y=0.5cm/3,
x=0.5cm,
grid=both,
xtick={0,...,10},
ytick={0,3,...,9},
xlabel=$x$, xlabel style={at={(1,0)}, anchor=west},
ylabel=$y$, ylabel style={rotate=-90,at={(0,1)}, anchor=south}
]
\end{axis}

\end{tikzpicture}

\end{document}

-
Your new code works fine here, which version of pgfplots do you have? You can add \listfiles to the preamble to get a list of packages printed at the end of the log file. –  Torbjørn T. Sep 1 '13 at 7:52

You have an empty line at the end of the axis options, remove this and it works fine.

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[samples=60,
domain=0:10, xmax=10.5,
restrict y to domain=0:10,
axis lines=left,
y=0.5cm/3,
x=0.5cm,
grid=both,
xtick={0,...,10},
ytick={0,3,...,9},
xlabel=$x$, xlabel style={at={(1,0)}, anchor=west},
ylabel=$y$, ylabel style={rotate=-90,at={(0,1)}, anchor=south}
]
\end{axis}
\end{tikzpicture}
\end{document}

-

As commented in Torbjørn T's answer, the problem is the blank line. Removing the blank line is the simple fix but arguably the underlying key-value parser ought to tolerate white space in the comma separated list. Adding the following to the preamble after loading the packages fixes this at least for the simple case where it is not hidden inside some other macro.

\makeatletter
\let\zz\pgfplots@environment@axis
\def\pgfplots@environment@axis{\endlinechar \zz}
\makeatother
`
-

Here it is working...

Maybe you're missing something in your preamble. Else you're not up-to-date.

-