Hello I would like to construct a Confusion Matrix as described here: confusion matrix using only LaTeX code

enter image description here

Unfortunately I have failed to adjust the code :(

I got as close as this thread, but the labels "actual" & "predicted" are not really centred. enter image description here

Can somebody help?

  • 1
    Welcome to TeX.SE. It looks like you've simply copied the image from the other answer. Can you at least expand that source to get the 3x3 matrix? We like to see at least some sort of attempt on this site. – Teepeemm Aug 27 '19 at 11:53

Hope the below code meets your requirement:


&\textbf{A} &0.1 &0.3 &0.5\\
&\textbf{B} &0.5 &0.2 &0.1\\
&\textbf{C} &0.4 &0.7 &0.2\\


And the output is:

enter image description here

|improve this answer|||||

After a coffee break I was able to answer it. :D

Still thank you for your help!!

enter image description here


%%%% Confusion Matrix Body %%%%
    \fbox{\parbox[c][3cm][c]{3cm}{\centering #1}}%
    % Size of boxes
    \parbox[c][1cm][c]{1cm}{\centering\bfseries #1}%
    \parbox[c][1cm][c]{#1}{\centering\bfseries #2}%


    \acro{TP}{True Positive}
    \acro{FP}{False Positive}
    \acro{TN}{True Negative}
    \acro{FN}{False Negative}





        \hspace*{1cm}\MyHBox{Cancelled}\MyHBox{Not Cancelled}\par


        \MyTBox{\rot{Not Cancelled}}{\ac{FP}}{\ac{TN}}



Because I am interested is there a better way to make Actual aligned in the middle with the same distance as Predicted. (My solution was try and error)

|improve this answer|||||

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.