# add unit circle to a plot

I have a point-by-point plot (pgfplots option only marks) in which I display the real and imaginary part of some points in the complex plane.

I would like to add the unit circle to the plot, for scale, that is, the circle $x^2+y^2=1$.

I have tried doing it with \draw (axis cs:0,0) circle (1);. However, the circle is way too small, since that radius "1" is not interpreted as having the same length as the unit length of the axes, but is an arbitrary unit. Of course axis cs:1 won't work, since 1 is not a coordinate pair but a single number. I do not see in the docs any equivalent of axis cs: for lengths.

Any suggestions on how to do it?

MWE:

\documentclass{standalone}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
coordinates
{(2,-1) (1.5,-2) (-1,0) (0,1) (0,0.5)};
\draw[color=red] (axis cs:0,0) circle (10);
\end{axis}
\end{tikzpicture}
\end{document}


(the circle radius has been scaled up to 10 to make it more visible; with 1 it would be very small)

Result:

-
Please add a minimal working example (MWE) that illustrates your problem. It's no fun to setup a file from scratch. When you post a compilable code, starting with \documentclass{...} and ending with \end{document} with your existing try-out (no matter how insufficient it is), everybody can jump in much easier. –  Claudio Fiandrino Mar 26 '13 at 10:44
A MWE is worth a thousand words... –  Jubobs Mar 26 '13 at 10:44
Added the MWE.~ –  Federico Poloni Mar 26 '13 at 11:19

There is a problem with the axis direction cs: way that I don't know why it is not working. You can still use the example in the manual p.257

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=5cm,height=8cm]
\draw \pgfextra{\pgfpathellipse{
\pgfplotspointaxisxy{0}{0}}
{\pgfplotspointaxisdirectionxy{1}{0}}
{\pgfplotspointaxisdirectionxy{0}{1}}
};
\end{axis}
\end{tikzpicture}
\end{document}


-
Ah, of course. The usual circle drawing \draw[blue] (axis cs:0,0) circle[radius=1]; requires \pgfplotsset{compat=1.5.1} –  percusse Mar 26 '13 at 11:27
Thanks, both methods work! (that example wasn't on my version of the manual) –  Federico Poloni Mar 26 '13 at 11:30
@FedericoPoloni v1.8 is just pushed or about to be pushed to CTAN. Get the latest while you are at it :) –  percusse Mar 26 '13 at 11:33

I'd be tempted just to add a circle parametrically

x(t)=cos(t)
y(t)=sin(t)


using

        \addplot [domain=0:2*pi,samples=50]({cos(deg(x))},{sin(deg(x))});


Complete MWE:

% arara: pdflatex
% !arara: indent: {overwrite: true}
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=5cm,height=8cm]