I am using the hack here to draw an axis in a tikzpicture and "recreate" the coordinate system in a scope after leaving the axis environment (in order to be able to use foreach commands). However, it seems that \pgfgetlastxy returns the coordinates in the wrong coordinate system. Consider this example
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\begin{axis}[ymin=0, ymax=1, xmin=0, xmax=1]
\coordinate (O) at (axis cs:0,0);
\coordinate (X) at (axis cs:1,0);
\coordinate (Y) at (axis cs:0,1);
\end{axis}
\begin{scope}[x={($(X)-(O)$)}, y={($(Y)-(O)$)}, shift={(O)}]
\coordinate (A) at (0.5, 0.5);
\path (A);
\pgfgetlastxy{\XCoord}{\YCoord};
\show\XCoord % Shows 97.49985pt
\show\YCoord % Shows 80.99976pt
\end{scope}
\end{tikzpicture}
\end{document}
How do I transform (97.49985pt, 101.2497pt) into the original (0.5,0.5)? Or better yet, is there a command that returns those coordinates?

