[Tex/LaTex] ‘Undefined control sequence’ with \addplot

pgfplotstikz-pgf

When trying to insert a TikZ figure, using \addplot, I've got an 'undefined control sequence'. My code is:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

\begin{tikzpicture}[scale=2]
\addplot[only marks] file[x index=0, y index=1]{baba.txt};
\end{tikzpicture}

\end{document}

where baba.txt is just the simple table:

0 1
1 0
1 1
0 0

Can anyone help me with this?

Best Answer

Is this what you want?

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

\begin{tikzpicture}[scale=2]
  \begin{axis}
\addplot+[only marks] file[x index=0, y index=1]{baba.txt};
  \end{axis}
\end{tikzpicture}

\end{document}