0

I'm new to LaTeX. This is a similar question to How to interpolate two colors in a cell?

The relative codes from the answer is helpful @user30471: The H column type uses the collcell package to apply the command \Heat to each cell entry. However, I have over 18 columns on my table. I tried to use \begin{tabular}{ cc *18H } to create heatmap tables as that question, but might the maximum number of columns allowed in \Heat is 9. I copied the \Heat code from @user30471. And my table code is:

\begin{document}
\begin{table}[h]
\centering
\caption{Summary of power ($\times1000$)... }
\setlength{\tabcolsep}{4.2pt}
\renewcommand{\arraystretch}{.8}
\begin{tabular}{r rrrrrr rrrrrr rrrrrr}
\toprule
     & \multicolumn{6}{c}{minp1} & \multicolumn{6}{c}{minp2} & \multicolumn{6}{c}{treep}\\
    \cmidrule(l){2-7}\cmidrule(l){8-13}\cmidrule(l){14-19}
    % \begin{sidewaystable}[h]
$\tau$ & i & ii & iii & iv & v & vi & i & ii & iii & iv & v & vi & i & ii & iii & iv & v & vi \\
\midrule
& \multicolumn{18}{c}{0\% censoring}\\
% \begin{sidewaystable}[h]
-0.8 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100\\ 
-0.6 & 97 & 98 & 98 & 97 & 98 & 98 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100\\
-0.4 & 76 & 76 & 76 & 76 & 76 & 76 & 90 & 92 & 92 & 91 & 91 & 92 & 87 & 88 & 88 & 84 & 88 & 88\\
-0.2 & 22 & 22 & 22 & 22 & 22 & 23 & 29 & 31 & 32 & 31 & 30 & 33 & 26 & 25 & 25 & 25 & 24 & 27\\
0 & 6 & 6 & 6 & 6 & 6 & 4 & 4 & 5 & 4 & 4 & 4 & 5 & 5 & 4 & 3 & 3 & 3 & 6\\
0.2 & 13 & 14 & 14 & 14 & 13 & 14 & 30 & 31 & 33 & 32 & 33 & 28 & 27 & 25 & 25 & 25 & 25 & 27\\
0.4 & 39 & 39 & 40 & 40 & 40 & 40 & 94 & 95 & 95 & 95 & 95 & 95 & 85 & 89 & 87 & 87 & 88 & 87\\
0.6 & 80 & 81 & 82 & 82 & 81 & 81 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100\\
0.8 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100\\    
[1ex]
& \multicolumn{18}{c}{25\% censoring}\\
-0.8 \\
% -0.7 \\
-0.6 \\
% -0.5 \\
-0.4 \\
% -0.3 \\
-0.2 \\
% -0.1 \\
0 \\
0.2 \\
0.4 \\
0.6 \\
0.8 \\
[1ex]
& \multicolumn{18}{c}{50\% censoring}\\
-0.8 \\
-0.6 \\
-0.4 \\
-0.3 \\
-0.2 \\
-0.1 \\
0 \\
0.2 \\
0.4 \\
0.6 \\
0.8 \\
\bottomrule
\end{tabular}
\label{tab: 1cut}

\end{table}

The figure is here: enter image description here I'd like to get the figure like this: enter image description here But it can only be up to 9 columns by:

  \Heatset{min=0,   % maximum value
           max=100,   % minimum value
           max colour=Gray0, % colour at maximum
           min colour=Snow1,      % colour at minimum
  }
\begin{table}[h]
\caption{Summary of power ($\times1000$)... }
\setlength{\tabcolsep}{4.2pt}
\renewcommand{\arraystretch}{.8}
\begin{tabular}{cc * 9H}
\toprule
& \multicolumn{3}{c}{minp1} & \multicolumn{3}{c}{minp2} & \multicolumn{3}{c}{treep}\\
\cmidrule(l){1-3}\cmidrule(l){4-6}\cmidrule(l){7-9}
& &\multicolumn1c{i}&\multicolumn1c{ii}&\multicolumn1c{iii}&\multicolumn1c{iv}&\multicolumn1c{v}&\multicolumn1c{vi}&\multicolumn1c{i}&\multicolumn1c{ii}&\multicolumn1c{iii}\\
& -0.8& 100& 100& 100& 100& 100& 100& 100& 100& 100\\
& -0.6& 97 & 98 & 98 & 97 & 98 & 98 & 100& 100& 100\\
& -0.4& 76 & 76 & 76 & 76 & 76 & 76 & 90 & 90& 90\\
& -0.2& 22 & 22 & 22 & 22 & 22 & 23 & 29& 29& 29 \\
\rotatebox{90}{\makebox[0pt]{\textsf{$\tau$}}}
& 0& 6 & 6 & 6 & 6 & 6 & 4 & 4& 4& 4\\
& 0.2& 13 & 14 & 14 & 14 & 13 & 14 & 30& 30& 30\\\
& 0.4& 39 & 39 & 40 & 40 & 40 & 40 & 94 & 94 & 94\\
& 0.6& 80 & 81 & 82 & 82 & 81 & 81 & 100 & 100& 100\\
& 0.8& 100& 100& 100& 100& 100& 100& 100& 100& 100\\
\end{tabular}
\end{table}

How to fill in heatmap colors in \begin{tabular}{r rrrrrr rrrrrr rrrrrr} by modifying my code? Or other ways to create a similar table?

  • Review - https://tex.stackexchange.com/a/401404/247020 – NotStanding with GoGotaHome Oct 15 '21 at 07:41
  • I think it is not heat map, a gradient something, the word "heat map" is confusing, specially it seems like the data has a relation with the heat map. Not a issue of your question :-). But might get a dupe-nuke from these: tex.stackexchange.com/q/174998/247020. Did you mean the gradients you would find in MS word or heatmaps as red=higher, blue=lower? – NotStanding with GoGotaHome Oct 15 '21 at 07:43
  • You should put a complete working example (with 9 columns). The, we could try to see whether it works for a larger number of columns and, if not, try to solve the problem. At this time, we don't have your MWE and that's why it's difficult to help you. – F. Pantigny Oct 17 '21 at 10:56

1 Answers1

1

When the column is greater than 9, it should be \begin{tabular}{cc * {10}H} not \begin{tabular}{cc * 10H}.

dexteritas
  • 9,161