# Figure with table, with both text and background colors within the cells of the table, and outside figure annotations

I am trying to draw a figure that includes a table 4x3 (probably combining tikzpicture and colortbl), with text and background colors (grayscale) within the cells, and some annotations outside the figure. I am looking for something similar to this:

But this is the closest I could get so far:

    \documentclass[a4paper,12pt]{article}
\usepackage{array}
\usepackage[svgnames,table]{xcolor}

\newcommand*{\arraycolor}[1]{\protect\leavevmode\color{#1}}
\newcolumntype{A}{>{\columncolor{Gray!22}}c}
\newcolumntype{B}{>{\columncolor{Gray!42}}c}
\newcolumntype{C}{>{\columncolor{Gray!72}}c}
\newcolumntype{D}{>{\columncolor{Gray!92}}c}

\begin{document}

\begin{center}
\sffamily
\arrayrulecolor{white}
\arrayrulewidth=1pt
\renewcommand{\arraystretch}{1.5}
\rowcolors[\hline]{3}{.!50!White}{}
\begin{tabular}{A|B|C|D|}
\rowcolor{.!50!Black}
\arraycolor{White}\bfseries &
\arraycolor{White}\bfseries A &
\arraycolor{White}\bfseries B &
\arraycolor{White}\bfseries C \\
A & Within 1 & Within 2 & Within 2 \\
B & Within 2 & Within 1 & Within 2\\
C & Within 2 & Within 2 & Within 1 \\
D & Out & Out & Out \\
\end{tabular}
\end{center}

\end{document}

• Please give us an MWE of what you have tried at least, to formally proceed to help you, escaping the context "do it for me" – J Leon V. Jul 16 '18 at 16:32
• What precisely is the question? Do you only want to add the braces or do you also want to adjust the colors? – user121799 Jul 16 '18 at 17:21

with tikz using library matrix is relatively simple:

\documentclass[tikz, margin=3mm]{standalone}
% temporary fix expl3 changes which not yet propagate to all package used it
\usepackage{expl3}
\ExplSyntaxOn
\int_zero_new:N \g__prg_map_int
\ExplSyntaxOff
% end of temporary fix
\usetikzlibrary{decorations.pathreplacing,
calligraphy,
matrix,
positioning}

\begin{document}
\begin{tikzpicture}[
node distance = 1mm and 3mm,
BC/.style = {decorate,
decoration={calligraphic brace, amplitude=3mm,
raise=#1, mirror}, thick, pen colour={gray}},
]
\matrix (m) [matrix of nodes,
nodes={draw, minimum size=20mm, outer sep=0pt},
column sep=-\pgflinewidth,
row sep=-\pgflinewidth,
column 1/.style={font=\bfseries},
row 1/.style={font=\bfseries},
CB/.style = {fill=black!80, text=white},
CG/.style = {fill=gray},
CS/.style = {fill=gray!50},
]
{       & A                 & B                 & C         \\
A   & |[CS]| Within 1   & |[CG]| Within 2   & |[CG]|Within 2  \\
B   & |[CG]| Within 2   & |[CS]| Within 1   & |[CG]|Within 2  \\
C   & |[CG]| Within 2   & |[CG]| Within 2   & |[CS]|Within 1  \\
D   & |[CB]| Out        & |[CB]| Out        & |[CB]|Out \\
};
\node[left =of m-3-1, rotate=90] {\textbf{Questioning}};
\draw[BC= 2mm] (m-4-4.south east) -- node[below= 4mm, sloped] {Partners} (m-1-4.north east);
\draw[BC=11mm] (m-5-4.south east) -- node[below=13mm, sloped] {All Members} (m-1-4.north east);
\end{tikzpicture}
\end{document}

• +1 Nice answer... – J Leon V. Jul 16 '18 at 19:39