\documentclass{article}

\usepackage{pgfplots}

\pgfplotsset{compat=1.9}

\begin{document}

\begin{tikzpicture}
%\tracingcommands=2\tracingmacros=2
	\begin{axis}[
		legend entries=x,
	]
	\addplot+[samples=2,
		legend image code/.code={%
			\draw[x=1cm,y=1cm] plot coordinates {(0,0) (1,1) (2,0)};
		},
	] {x};	
	\end{axis}

\end{tikzpicture}

\begin{tikzpicture}
	% does also change the coordinate system
	\begin{axis}[legend entries=$xy$]
	\addplot3[surf,samples=2] {x*y};
	\end{axis}
\end{tikzpicture}
\end{document}

