2

I did a matrix with Latex, but I do not know how how to do the colored square. Any idea please?

Thank you

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{collcell}
\usepackage{hhline}
\usepackage{pgf}

\newcommand\gray{gray}

\newcommand\ColCell[1]{%
  \pgfmathparse{#1<.8?1:0}%
    \ifnum\pgfmathresult=0\relax\color{white}\fi
  \pgfmathparse{1-#1}%
  \expandafter\cellcolor\expandafter[%
    \expandafter\gray\expandafter]\expandafter{\pgfmathresult}#1}

\newcolumntype{E}{>{\collectcell\ColCell}c<{\endcollectcell}}

\begin{document}

\noindent\begin{tabular}{c*{6}{|E}|}
 \multicolumn{1}{c}{} & \multicolumn{1}{c}{hw} & \multicolumn{1}{c}{bx} 
  & \multicolumn{1}{c}{wk} & \multicolumn{1}{c}{jg} & \multicolumn{1}{c}{cl} 
  & \multicolumn{1}{c}{rn} \\ \hhline{~*6{|-}|}
 ving & 1 & 0 & 0 & 0 & 0 & 0 \\ \hhline{~*6{|-}|}
 xing & 0 & 0.92 & 0.08 & 0 & 0 & 0 \\ \hhline{~*6{|-}|} 
 king & 0 & 0.03 & 0.97 & 0 & 0 & 0 \\ \hhline{~*6{|-}|}
 ging & 0 & 0 & 0 & 1 & 0 & 0 \\ \hhline{~*6{|-}|}
 ping & 0 & 0 & 0 & 0 & 1 & 0 \\ \hhline{~*6{|-}|}
 ning & 0 & 0 & 0 & 0 & 0 & 1 \\ \hhline{~*6{|-}|}
\end{tabular}\par\bigskip
\end{document}

desired output

Alenanno
  • 37,338
Fish
  • 93

0 Answers0