[Tex/LaTex] TikZ: xshift not shifting

tikz-pgf

Why wont xshift work here?

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
  \coordinate (Q) at (2.1cm, -1cm);

  \draw[xshift = 0.5cm] (Q) -- +(0, 3cm); % no shift

  \begin{scope}[xshift = 0.5cm]
    \draw (Q) -- +(0, 3cm); % no shift
  \end{scope}
\end{tikzpicture}
\end{document} 

Both the scoped and non-scoped version produce the same image:

enter image description here

As we can see, the line is drawn from Q and not shifted.

Best Answer

As explained in another answer, named nodes are somewhat "absolute" coordinates, and they are not affected by standard transforms (shift, rotate, scale, etc.) They can be transformed via a transform canvas, however, but this is generally discouraged, specially for scale changes, because it affects also to the size and aspect of strokes, fonts, etc.

So, leaving shifts alone, which alternatives do we have?

  1. Use calc to manually add some amount to each coordinate, e.g: ($(Q)+(0.5, 0)$)
  2. Use ++ syntax to set a new "origin" and + syntax to specify coordinates relative to that origin.

Using the second approach for this particular case:

\draw (Q) ++(0.5, 0) -- +(0,3);

which means:

  1. Go to coordinate (Q)
  2. Move (0.5,0) from that coordinate and set this new point as origin for relative coordinates
  3. Draw a line from the last point to the one which is at (0,3) from it.