TeX - LaTeX Asked by super_ask on July 4, 2021
I am new to latex and in a pressing need to quickly design a fine confusion matrix (with text rotation) as in the attached screenshot:
I am not sure how the content can be customised in latex as in the shown table (Predicted column orientation, double-line horizontal line etc).
Any help would be appreciated.
EDIT
I would have love to use @Zarko's answer since I'm using `ieeetran` document class but I encountered an error:
The compiler is having trouble understanding a command you have used. Check that the command is spelled correctly. If the command is part of a package, make sure you have included the package in your preamble using usepackage{...}.
with some options defined in the command appearing in the output:
I suspect that you use ieeetran
or similar document class. With employed siunitx
package (for S
columns), booktabs
(for horizontal rules), multirow
(for cell with vertical text), and rotating
and makecell
(for rotate text in the first column) packages:
documentclass{ieeetran}
usepackage{rotating}
usepackage{booktabs, makecell, multirow}
NewExpandableDocumentCommandmcc{O{1}m}
{multicolumn{#1}{c}{#2}}
usepackage{siunitx}
begin{document}
begin{table}[ht]
caption{Confusion matrix for SVM using pooled features}
label{tab:confusion}
settowidthrotheadsize{textbf{Predicted}}
centering
begin{tabular}{*{2}{>{bfseries}l} *{6}{S[table-format=2.2]} }
toprule
& & mcc[6]{textbf{Actual}}
cmidrule{3-8}
& & {textbf{Bike}} & {textbf{Car}} & {textbf{Walk}}
& {textbf{Run}} & {textbf{Bus}} & {textbf{Precision}}
midrule
multirow{5}{*}{rothead{Predicted}}
& Bike
& 97.13 & 0.52 & 1.17
& 0.40 & 0.58 & 97.88
& Car & 0.66 & 93.57 & 0.16
& 0.13 & 3.06 & 95.88
& Walk & & & & & &
& Run & & & & & &
& Bus & 0.92 & 2.42 & 0.40
& 0.32 & 93.11 & 95.81
midrule
& Recall
& 97.13 & 93.57 & 93.82
& 92.82 & 93.11 &
bottomrule
end{tabular}
end{table}
end{document}
Correct answer by Zarko on July 4, 2021
For double lines in tables you can use hhline
package.
For rotation of text in tables rotatebox
. (explanation see here)
documentclass{article}
usepackage{hhline}
usepackage{booktabs}
usepackage{multirow}
usepackage{adjustbox}
newcommandRotText[1]{rotatebox{90}{parbox{1.9 cm}{raggedright#1}}}
begin{document}
begin{table}[h]
renewcommand{arraystretch}{1.25}
%caption{Table}
label{tab:my-table}
centering
setlengthdoublerulesep{0.8pt} % distance or the 2 lines in the double line
begin{tabular}{cccccccc}
specialrule{2pt}{1pt}{1pt} % thick line
multicolumn{8}{c}{textbf{Actual}}
multicolumn{2}{c}{textbf{}} & textbf{Bike} & textbf{Car} & textbf{Walk} & textbf{Run} & textbf{Bus} & textbf{Precision} hline
multirow{5}{*}{textbf{RotText{Predicted}}}
& textbf{Bike} & 97.13 & 0.52 & 1.1 7& 0.40 & 0.58 & 97.33
& textbf{Car} & 0.66 & 93.57 & 0.16 & 0.13 & 3.06 & 95.88
& textbf{Walk} & 0.29 & 0.08 & 93.59 & 0.92 & 0.29 & 97.68
& textbf{Run} & 0.37 & 0.05 & 0.93 & 92.82 & 0.20 & 98.36
& textbf{Bus} & 0.92 & 2.42 & 0.40 & 0.32 & 93.11 & 95.81 hline
& textbf{Recall} & 97.13 & 93.57 & 93.59 & 92.82 & 93.11 & hhline{========}
end{tabular}
end{table}
end{document}
Answered by Roland on July 4, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP