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:
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?
calc
to manually add some amount to each coordinate, e.g:($(Q)+(0.5, 0)$)
++
syntax to set a new "origin" and+
syntax to specify coordinates relative to that origin.Using the second approach for this particular case:
which means:
(Q)
(0.5,0)
from that coordinate and set this new point as origin for relative coordinates(0,3)
from it.