If I draw a path with the -|
(horizontal-first-then-vertical) or |-
(vertical-first-then-horizontal) commands and decorate the path with the snake
-morphing operation, the latter half of the path is misplaced.
Here is an example:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\path[draw=red, ->] (0,0) -| (5,5);
\path[draw=black,->,decorate,decoration={snake}] (0,0) -| (5,5);
\end{tikzpicture}
\caption{Wrong}
\end{figure}
\begin{figure}
\centering
\begin{tikzpicture}
\path[draw=red, ->] (0,0) -| (5,5);
\path[draw=blue,->,decorate,decoration={snake}] (5,0) -- (5,5);
\end{tikzpicture}
\caption{Correct}
\end{figure}
\end{document}
In this special case the (black) vertical part has an offset by the same amount as the amplitude of the snake, i.e. the black sine curve is not centered around the red vertical path. The second figure shows how the sine curve is actually expected to look like (cp. blue curve).
The amount of displacement varies with the actual values of the coordinates and it happens to look really ugly in combination with the arrow head, because the arrow remains centered at the correct position.
How do I fix this?
-|
as you can check this by replacing it by(0,0) -- (5,0) -- (5,5)
. This looks like an imprecision bug to me.