2

I would like to make a confusion matrix that looks like the one on the picture. How can I achive this? Thanks enter image description here

1

2 Answers 2

3

Quite hard coded, but you may start with this:

% arara: pdflatex

\documentclass{article}
\usepackage{blkarray}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{mathtools}

\begin{document}    
\[
\renewcommand{\arraystretch}{1.6}
\begin{blockarray}{c@{}ccc}
&&\BAmulticolumn{2}{c}{\text{observed}}\\[-2\jot]
&& 0 & 1 \\
\begin{block}{c@{\hspace{.6em}}c[cc]}
\multirow{2}{*}{\rotatebox[origin=c]{90}{predicted}} & 0 & a=1 & b=2\\
& 1 & c=3 & d=4 \\
\end{block}
\end{blockarray}
\]
\end{document}

enter image description here

1
  • @OlgaLyashevska Glad to hear that.
    – LaRiFaRi
    Jul 13, 2015 at 14:11
3

With {NiceMatrix} of the eponymous package.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\renewcommand{\arraystretch}{1.2}
$\begin{NiceMatrix}
  &   & \Block{1-2}{\text{observed}} \\
  &   & 0   & 1 \\
  \Block{2-1}{\rotate \text{predicted}}
  & 0 & a=1 & b=2 \\[1mm]
  & 1 & c=2 & d=4 
\CodeAfter 
  \SubMatrix[{3-3}{4-4}]
\end{NiceMatrix}$

\end{document}

Output of the above code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.