The main reason why your approach does not quite work is that the nodes have some standard dimensions, most notably inner sep, which distorts the (vertical) position of your bar node. If you remove the inner sep, the bar will sit right below the baseline that is in the middle. You could then shift it down by half its thickness. It is, however, easy enough to draw a perfectly (I hope;-) centered bar with TikZ methods.
\documentclass[border=1pt,varwidth=5cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\newcommand\colorrulemix[1]{\textcolor{#1!40!gray}{\rule{0.5cm}{0.5cm}} }
\newcommand\colorrule[1]{\textcolor{#1}{\rule{0.5cm}{0.5cm}} }
Your picture:\\
\begin{tikzpicture}[node distance=0]
\foreach \name [count=\i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
\node (P\i) at (\i*0.6cm,0) {\colorrule{\name}};
}
\node[below=0.1 of P4] {\rule{4.5cm}{1pt}};
\foreach \name [count=\i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
\node [below=0.2 of P\i] (Q\i) {\colorrulemix{\name}};
}
\end{tikzpicture}
Your picture with \texttt{inner sep=0pt}:\\
\begin{tikzpicture}[node distance=0]
\foreach \name [count=\i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
\node (P\i) at (\i*0.6cm,0) {\colorrule{\name}};
}
\node[below=0.1 of P4,inner sep=0pt] {\rule{4.5cm}{1pt}};
\foreach \name [count=\i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
\node [below=0.2 of P\i] (Q\i) {\colorrulemix{\name}};
}
\end{tikzpicture}
Your picture with \texttt{inner sep=0pt} and a cross--check:\\
\begin{tikzpicture}[node distance=0]
\foreach \name [count=\i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
\node (P\i) at (\i*0.6cm,0) {\colorrule{\name}};
}
\node[below=0.1 of P4,inner sep=0pt] {\rule{4.5cm}{1pt}};
\foreach \name [count=\i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
\node [below=0.2 of P\i] (Q\i) {\colorrulemix{\name}};
}
\path (Q1) -- (P1) coordinate[midway] (aux) ;
\draw[red](aux) -- ++ (4,0);
\end{tikzpicture}
An alternative with really centered line:\\
\begin{tikzpicture}[node distance=0]
\foreach \name [count=\i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
\node (P\i) at (\i*0.6cm,0) {\colorrule{\name}};
}
\foreach \name [count=\i] in {{red},{orange},{yellow},{green},{cyan},{blue},{purple}} {
\node [below=0.2 of P\i] (Q\i) {\colorrulemix{\name}};
}
\path (Q4) -- (P4) coordinate[midway] (aux) ;
\draw[line width=1pt]([xshift=-2.25cm]aux) -- ++ (4.5,0);
\end{tikzpicture}
\end{document}
