I'm trying to learn TikZ. I would like an edge between two nodes but vertically shifted down a bit.
Why is this not working? Seems to only shift down on one side.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations, arrows}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (10,0);
\foreach \x in {0,2,4,7,9}
\draw (\x cm,3pt) -- (\x cm,-3pt);
% draw nodes
\draw (0,0) node[below=3pt](A) {$ 0 $} node[above=3pt] {$ $};
\draw (1,0) node[below=3pt](B) {$ $} node[above=3pt] {$ Y_{i1} $};
\draw (2,0) node[below=3pt](C) {$ t_{i1} $} node[above=3pt] {$ $};
\draw (3,0) node[below=3pt](D) {$ $} node[above=3pt] {$ Y_{i2} $};
\draw (4,0) node[below=3pt](E) {$ t_{i2} $} node[above=3pt] {$ $};
\draw (5.5,0) node[below=3pt](F) {$ $} node[above=3pt] {$ Y_{i3} $};
\draw (7,0) node[below=3pt](G) {$ t_{i3} $} node[above=3pt] {$ $};
\draw (8,0) node[below=3pt](H) {$ $} node[above=3pt] {$ Y_{i3} $};
\draw (9,0) node[below=3pt](I) {$ t_{i4} $} node[above=3pt] {$ $};
%\draw[latex'-latex'] (A) -- (C);
\draw[latex'-latex'] ([yshift=-5cm]A) -- ([yshift=-5cm]C);
\draw[latex'-latex'] (C) -- (E);
\draw[latex'-latex'] (E) -- (G);
\end{tikzpicture}
\end{document}
Best Answer
For example, the arrow can be shifted the following way. As anchor point for the shift, the example uses the
north *
anchors, to avoid a slanted line because of the different heights of the nodes.If you want to correct the first arrow and move the left side down to get a horizontal line, then this can be achieved much easier via a
\vphantom
: