Sunday, 26 May 2013

Extracting x, y coordinates of an arbitrary point in TiKZ while using yscale and xscale

Extracting x, y coordinates of an arbitrary point in TiKZ while using yscale and xscale

Inspired by Extract x, y coordinate of an arbitrary point in TikZ, I am trying to use the x coordinate of a point to draw another element.
However, when I use the yscale and xscale commands, the extracted coordinates do not similarly scale up. Here is an example:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}

\draw[->] (0,0) -- (2,0) ;
\draw[->] (0,0) -- (0,2) ; 

\coordinate (z) at (0.5,0);
\path (z) node[below] {$z$};
\pgfgetlastxy{\XCoord}{\YCoord};

\coordinate (kink) at (\XCoord,\XCoord);

\draw[gray] (0,0) -- (kink) node[above, red] {$c$};

\end{tikzpicture}

\begin{tikzpicture}[yscale=4,xscale=6]

\draw[->] (0,0) -- (2,0) ;
\draw[->] (0,0) -- (0,2) ; 

\coordinate (z) at (0.5,0);
\path (z) node[below] {$z$};
\pgfgetlastxy{\XCoord}{\YCoord};

\draw[gray] (0,0) -- (kink) node[above, red] {$c$};

\end{tikzpicture}

\end{document}
In the first picture, the extracted coordinate works as expected. In the second picture, I try to scale up the entire picture, but the extracted coordinate remains in its original scale. How do I get the extracted coordinate to also scale up?

No comments:

Post a Comment