I am Charmie

メモとログ

Confusion matrix with LaTeX

The following code generates a confusion matrix whose diagonal elements have colored background.
ConfusionMatrix

[code language="latex"] \documentclass{article} \usepackage{tabularx} \usepackage{colortbl} \usepackage{hhline}

\begin{document}

\begin{tabularx}{.7\textwidth}{>{\bfseries}c|c c c |} & A & B & \multicolumn{1}{c}{C} \ \hhline{----} A & 4 \cellcolor[gray]{.8}& 1 & 0 \ B & 0 & 5 \cellcolor[gray]{.8}& 0 \ C & 0 & 2 & 3 \cellcolor[gray]{.8} \ \hhline{~---} \end{tabularx}

\end{document} [/code]