我是乳胶的新手,迫切需要快速设计一个精细的混淆矩阵(带有文本旋转),如所附的屏幕截图所示:
我不确定如何在乳胶中定制内容,如所示的表格(预测列方向,双线水平线等)。
任何帮助,将不胜感激。
编辑
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{...}.
答案1
我怀疑您使用ieeetran
或类似的文档类。使用siunitx
包(用于S
列)、booktabs
(用于水平规则)、multirow
(用于具有垂直文本的单元格)和\rotating
(makecell
用于旋转第一列中的文本)包:
\documentclass{ieeetran}
\usepackage{rotating}
\usepackage{booktabs, makecell, multirow}
\NewExpandableDocumentCommand\mcc{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}
\settowidth\rotheadsize{\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}
答案2
对于表格中的双线,您可以使用hhline
包。
对于表格中的文本旋转\rotatebox
。(解释见这里)
\documentclass{article}
\usepackage{hhline}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{adjustbox}
\newcommand\RotText[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
\setlength\doublerulesep{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}