# Why yshift doesn't work in this TikZ example?

Any idea why yshift doesn't work in the following TikZ example?

\documentclass{minimal}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (2.5,0);
\draw (A) -- (B);
\draw[yshift=2cm] (A) -- (B);
\end{tikzpicture}

\end{document}

-
possible duplicate of Shifting a line joining nodes in TikZ –  Marco Daniel May 24 '13 at 10:16

It would work with coordinates or if you place the yshift inside the parentheses next to the name A and B:

\documentclass{minimal}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (2.5,0);
\draw (A) -- (B);
\draw ([yshift=2cm]A) -- ([yshift=2cm]B);
\end{tikzpicture}

\end{document}


Output:

-
Thanks but it looks odd the way yshift is specified. Any idea why? –  Leo Liu Aug 11 '10 at 13:20
Coordinate transformations do not apply to a node. Its anchor remains the same. See section 15.11 of the pgf manual. –  Stefan Kottwitz Aug 11 '10 at 13:38
I didn't know that one can apply transformations this way to coordinates (I would have used ($(A) - (0,2cm)$)) and the calc library. –  Caramdir Aug 11 '10 at 13:40
Before the calc library ([yshift=2cm]A) was the only method, now we have the choice. –  Alain Matthes Mar 8 '12 at 22:57
yshift (and similar commands) are applied to all coordinates in the path, not to the path as a whole. They are also not applied to anchors: according to the TikZ manual (section 15.11. in the 2.0 version):