I'm attempting to use TikZ to draw three different coordinate frames. I have successfully done it already. However, in an attempt to make my code more readable, I tried breaking it down into a more spread out and sequential manner. The second implementation (shown below) produces a totally different result than the first Below are both blocks of code, the first which works and second that does not. My question is why are these very similar implementations producing different results?
First implemenation
\documentclass[10pt, fleqn]{article}
\usepackage{tikz}
\usetikzlibrary{automata, arrows, positioning, fit, petri}
\begin{document}
\begin{tikzpicture}[ultra thick, scale = 2]
\foreach \tilt / \ylength / \xlength / \ylabel / \xlabel in { 0/3/4/{y}/{x}, -45/4/1.5/{q'}/{d'}, -60/4/1.5/{q}/{d} }
\draw [<->, rotate=\tilt] (0, \ylength) node (yaxis) [above] {\ylabel} |- (\xlength, 0) node (xaxis) [right] {\xlabel};
\end{tikzpicture}
\end{document}
Second Implementation
\documentclass[10pt, fleqn]{article}
\usepackage{tikz}
\usetikzlibrary{automata, arrows, positioning, fit, petri}
\begin{document}
\begin{tikzpicture}[ultra thick, scale = 2]
%% Define y-axis nodes for rotational reference frames
\foreach \nodename / \axislength / \axislabel in { {yaxis}/3/{y}, {yaxis}/4/{q}, {yaxis}/4/{q'} }
\node (\nodename) at (0, \axislength) [above] {\axislabel};
%% Define x-axis nodes for rotational reference frames
\foreach \nodename / \axislength / \axislabel in { {xaxis}/4/{x}, {xaxis}/1.5/{d}, {xaxis}/1.5/{d'} }
\node (\nodename) at (\axislength, 0) [right] {\axislabel};
%% Connect nodes to form rotational reference frames
\foreach \tilt / \nodenamey / \nodenamex in { 0/{yaxis}/{xaxis}, -45/{yaxis}/{xaxis}, -60/{yaxis}/{xaxis} }
\draw [<->, rotate=\tilt] (\nodenamey) |- (\nodenamex);
\end{tikzpicture}
\end{document}
Thanks for all help in advance!
Package pgf Error: No shape named {xaxis} is known. But, I believe the problem is that tha\foreachforms a local group. So, any nodes you define inside it are not available outside in the next\foreach. – Peter Grill Sep 24 '13 at 00:14{xaxis}which is picked up by\foreach. – Qrrbrbirlbel Sep 24 '13 at 00:25name path globalissue as in Is there a way to clear paths previously defined with name path global in TikZ, but that is not a node. – Peter Grill Sep 24 '13 at 05:29\foreach \tilt in { 0,-45,-60}\draw [<->, rotate=\tilt] (yaxis) |- (xaxis);– percusse Sep 24 '13 at 07:56