[Tex/LaTex] Specify radius of an arc with pgfplots and axis direction cs

arcpgfplots

I'm trying to draw an arc (the top half of a circle of radius 8, centered at (-8,0)) but I can't figure out how to specify the radius in pgfplots's coordinate system. Here's a MWE:

\pgfplotsset{compat=1.5.1}
\begin{tikzpicture}
  \begin{axis}[
      xmin=-20,xmax=20,
    ]
    \addplot{x}; % not important, just to make things show up
    \draw (axis cs:-16,0) arc[start angle=180, end angle=0,
                              radius=8];
  \end{axis}
\end{tikzpicture}

I read about axis direction cs in the pgfplots manual, but it doesn't explain how to use it to calculate a distance like a radius — it only says that for ellipses, it's done automatically. But I don't have an ellipse, I have an arc.

How can I specify a radius of 8 for my arc, using the coordinate system of my plot?

Best Answer

You can transform the distance for the radius using the function transformdirectionx (which is the math parser equivalent to \pgfplotstransformdirectionx):

\documentclass{article}

\usepackage{pgfplots}
\pgfplotsset{compat=1.5.1}
\begin{document}

\begin{tikzpicture}
  \begin{axis}[
      xmin=-10,xmax=10,
      axis equal,
      grid=both
    ]
    \addplot{x};
    \draw [ultra thick] (axis cs:0,-5) arc[start angle=-90, end angle=180,
                              radius={transformdirectionx(5)}];
  \end{axis}
\end{tikzpicture}
\end{document}