# “Package pgfplots Error: Could not read table file” in Beamer

I am trying to plot a Tikz figure on a Beamer slide but receive the following error:

! Package pgfplots Error: Could not read table file '" x y 0.8 0.8 1. 0.8 1. 1. 0.8 1. 0.9 0.8 1. 0.9 0.9 1. 0.8 0.9 0.9 0.9 "'. In case you intended to provide inline data: maybe TeX screwed up your end-of-lines? Try 'row sep=crcr' and terminate your lines with '\\' (refer to the pgfplotstable manual for details).

Here is the Beamer presentation that generated this error:

\documentclass[]{beamer}
\usepackage{pgfplots}
\usepgfplotslibrary{patchplots}
\begin{document}
\begin{frame}
\begin{tikzpicture} \begin{axis}[view={40}{40},xmin=0,xmax=1,ymin=0,max=1,zmin=0,zmax=1]
x   y
0.8 0.8
1.  0.8
1.  1.
0.8 1.
0.9 0.8
1.  0.9
0.9 1.
0.8 0.9
0.9 0.9
};
\end{axis}
\end{tikzpicture}
\end{frame}
\end{document}


I tried the suggested solution to no avail:

\documentclass[]{beamer}
\usepackage{pgfplots}
\usepgfplotslibrary{patchplots}
\begin{document}
\begin{frame}
\begin{tikzpicture} \begin{axis}[view={40}{40},xmin=0,xmax=1,ymin=0,max=1,zmin=0,zmax=1]
x   y\\
0.8 0.8\\
1.  0.8\\
1.  1.\\
0.8 1.\\
0.9 0.8\\
1.  0.9\\
0.9 1.\\
0.8 0.9\\
0.9 0.9\\
};
\end{axis}
\end{tikzpicture}
\end{frame}
\end{document}


When I put the same tikzpicture into an article class document, the code compiles as expected. Does anybody know what is the cause of this error in Beamer?

Add the [fragile] option to the frame:

\begin{frame}[fragile]


Probably, when beamer is scanning the frame environment, it's loosing the line ends and the table structure because the contents are sent back and forth between various macros. The easiest is to read the table outside the frame and use the table name. But alternatively, you can make the column and rows separated with a nontrivial symbol

\documentclass[]{beamer}
\usepackage{pgfplots}
\usepgfplotslibrary{patchplots}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\begin{axis}[view={40}{40},xmin=0,xmax=1,ymin=0,max=1,zmin=0,zmax=1]
table[z expr=x^2*y^2,x=x,y=y,col sep=comma,row sep=crcr] {
x,y\\
0.8, 0.8 \\
1. , 0.8 \\
1. , 1.  \\
0.8, 1.  \\
0.9, 0.8 \\
1. , 0.9 \\
0.9, 1.  \\
0.8, 0.9 \\
0.9, 0.9 \\
};
\end{axis}
\end{tikzpicture}
\end{frame}
\end{document}