# Keep position of coordinates with different axis-scale

How can I keep the position of a coordinate when I use it in another environment with a different axis-scale?

In the example, I would like the \node [...] at (c); in the right picture to be in the position of the red point instead of scaling the y-coordinate with the axis-scale.

\documentclass{standalone}
\usepackage{tikz,pgfplots}

\begin{document}
\begin{tikzpicture}[x=0, y=0]
\begin{axis}[
xmin=0,
xmax=1,
ymin=0,
ymax=1
]
\node (c) at (0.6,0.8){};
\node [circle,inner sep=2pt,fill=white,draw] at (c) {};
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}[x=0, y=0]
\begin{axis}[
xmin=0,
xmax=1,
ymin=0,
ymax=10
]
\node [circle,inner sep=2pt,fill=white,draw] at (c) {};
\node [circle,inner sep=2pt,draw,red] at (0.6,0.8) {};
\end{axis}
\end{tikzpicture}
\end{document}


Simplest way is to just define a macro for the coordinate and reuse it:

## Code:

\documentclass{standalone}
\usepackage{tikz,pgfplots}

\newcommand*{\SpecialPoint}{0.6,0.8}

\begin{document}
\begin{tikzpicture}[x=0, y=0]
\begin{axis}[
xmin=0,
xmax=1,
ymin=0,
ymax=1
]

\node [circle,inner sep=2pt,fill=white,draw] at (\SpecialPoint) {};
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}[x=0, y=0]
\begin{axis}[
xmin=0,
xmax=1,
ymin=0,
ymax=10
]
\node [circle,inner sep=2pt,fill=blue,draw,overlay] at (\SpecialPoint) {};
\node [circle,inner sep=2pt,draw,red] at (0.6,0.8) {};
\end{axis}
\end{tikzpicture}
\end{document}

• ok that helps for my defined points, thanks a lot. I have also points calculated with intersections. Is there a way to do the same with those? (Sorry for not mentioning that in the minimal I tried to keep it as short as possible.) – kash Jun 21 '15 at 12:26
• @kash: You should be able to adapt a solution from Extract x, y coordinate of an arbitrary point in TikZ. I will try to look into that tomorrow, but in case you were in a rush thought I'd give you a pointer for now. – Peter Grill Jun 22 '15 at 10:25
• Yes that was what I was trying to adapt already before, but it didn't work out. Now I tried it again and at least found out that \pgfgetlastxy does not seem to work out when you use axis with \usepackage{pgfplots). – kash Jun 22 '15 at 13:11
• Well, I use a workaround now (I just keep the axis-scale the same in both pictures now). Maybe I try to find a solution for the problem above later. Thanks you for the effort! – kash Jun 22 '15 at 13:25

You should define the point outside of all axes to be independent of the axis used. Since (c) is a coordinate, you can simply define it by \def\Pointc{0.6,0.8}.

\documentclass{standalone}
\usepackage{tikz,pgfplots}

\begin{document}
\def\Pointc{0.6,0.8}

\begin{tikzpicture}[x=0, y=0]
\begin{axis}[
xmin=0,
xmax=1,
ymin=0,
ymax=1
]
\node [circle,inner sep=2pt,fill=white,draw] at (\Pointc) {};
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}[x=0, y=0]
\begin{axis}[
xmin=0,
xmax=1,
ymin=0,
ymax=10
]
\node [circle,inner sep=2pt,fill=blue,draw] at (\Pointc) {};
\node [circle,inner sep=2pt,draw,red] at (0.6,0.8) {};
\end{axis}
\end{tikzpicture}
\end{document}

• Careful about redefining one letter macros such as \c, many of them are used. With \def you will not even be told that you're overwriting an existing macro, while with \newcommand you will. – Torbjørn T. Jun 21 '15 at 8:25
• Yes, we are better off naming it \Pointc, for example, I edited my answer. I just wanted to give the OP the basic idea. Since Pointc is not a command but a coordinate, I will never declare it by \newcommand. Besides, I never used those single-letter macros in a document (especially in English). – AboAmmar Jun 21 '15 at 15:09