[Tex/LaTex] \hhline adds white line where no line is intended

colorrulestables

In a table, containing colored cells, i want to have a \hline dividing only some cells, similar to \cline but compatible with coloring single cells with \cellcolor, which is possible by using \hhline with fitting parameters.

Now I have come to the appended code, which results in:
tables_hhline

There are two points I want to work around.

First, the black cells should not be crossed by a white line. Since they will not be black in the final document, I need them to be not black, either. Is there a way to not draw any line at all? These cells should look like a multirow cell, colored consistently.

The second problem are the hline fragments at the right end of the table. How can I get rid of them?

Complete code:

\documentclass[11pt]{article}

\usepackage{color}
\usepackage{colortbl}
\usepackage{multirow}
\usepackage{hhline}

\setlength{\arrayrulewidth}{1pt}


\begin{document}
% Empty table
\begin{tabular}{*{5}{!{\vrule width 1.5pt}p{1.5cm}}!{\vrule width 1.5pt}l}
\centering 4 &
\centering 10 &
\centering 24 &
\centering 48 &
\centering 72 &\\ \hhline{*{5}{|-}|~|}
 &  &  &  &  & Optic tectum \\ \hhline{*{2}{|~}*{3}{|-}|~|}
 &  &  &  &  & Retina \\ \hhline{*{2}{|~}*{3}{|-}|~|}
 &  &  &  &  & Myomeres \\ \hhline{*{5}{|-}|~|}
 &  &  &  &  & Arches \\ \hhline{*{5}{|-}|~|}
\end{tabular} \\

\hspace*{1cm}

% Partically filled table
\begin{tabular}{*{5}{!{\vrule width 1.5pt}p{1.5cm}}!{\vrule width 1.5pt}l}
\centering 4 &
\centering 10 &
\centering 24 &
\centering 48 &
\centering 72 &\\ \hhline{*{5}{|-}|~|}
 & \cellcolor{black} &  & \cellcolor{green} &  & Optic tectum \\ \hhline{*{2}{|~}*{3}{|-}|~|}
 & \cellcolor{black} &  & \cellcolor{red} &  & Retina \\ \hhline{*{2}{|~}*{3}{|-}|~|}
 & \cellcolor{black} &  & \cellcolor{blue} &  & Myomeres \\ \hhline{*{5}{|-}|~|}
 & \cellcolor{blue} &  & \cellcolor{yellow} &  & Arches \\ \hhline{*{5}{|-}|~|}
\end{tabular}

\end{document}

Best Answer

You are specifying a final hhline fragment

\hhline{*{2}{|~}*{3}{|-}|~|}

You need

 \hhline{*{2}{|~}*{3}{|-}|~}

The "white line" is not a rule drawn over the black background it is just a lack of background, thus you need to fill it, the easiest way, as shown in the previous question is not to use ~ in the \hhline (which does exactly what you ask and does not draw any line at all) but instead use - but colour the rule using >{...} to match the cell colour.