Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.
<to be read again> 
                   \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},
    compat=newest,
    xlabel=$x$, xlabel style={at={(1,0)}, anchor=west},
    ylabel=$y$, ylabel style={rotate=-90,at={(0,1)}, anchor=south}

]
\addplot [red] {x};
\addplot [black] {x^2};
\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},
    compat=newest,
    xlabel=$x$, xlabel style={at={(1,0)}, anchor=west},
    ylabel=$y$, ylabel style={rotate=-90,at={(0,1)}, anchor=south}
]
\addplot [red] {x};
\addplot [black] {x^2};
\end{axis}

\end{tikzpicture}

\end{document}
share|improve this question
    
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

3 Answers 3

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},
    compat=newest,
    xlabel=$x$, xlabel style={at={(1,0)}, anchor=west},
    ylabel=$y$, ylabel style={rotate=-90,at={(0,1)}, anchor=south}
]
\addplot [red] {x};
\addplot [black] {x^2};
\end{axis}
\end{tikzpicture}
\end{document}
share|improve this answer

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
share|improve this answer

Here it is working...

Plot result

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.