我正在使用 Springer LNCS 模板来创建论文,因此我无法使用subcaption
pgfplotssubfigure
导致根本没有对齐。
我用来绘制图表的代码:
\begin{figure}
\centering
\subfigure{
\begin{tikzpicture}
\begin{axis}[
ybar = 0pt,
scale = 0.6,
/pgf/number format/1000 sep={},
xticklabels={Bayes, Tree, kNN, SVM},
xtick = {1,2,3,4,5},
ymin = 0,
ymax = 100,
enlarge x limits=0.25,
legend cell align=left,
legend style={
at={(1,1.05)},
anchor=south east,
column sep=1ex
}
]
\addplot coordinates {
(1, 68) (2, 70) (3, 67) (4, 66)
};
\addplot coordinates {
(1, 70) (2, 71) (3, 72) (4, 68)
};
\legend{unmodified, modified}
\end{axis}
\end{tikzpicture}
}
\subfigure{
\begin{tikzpicture}
\begin{axis}[
ybar=0pt,
scale = 0.6,
/pgf/number format/1000 sep={},
xticklabels={Bayes, Tree, kNN, SVM},
xtick = {1,2,3,4,5},
ymin = 0,
ymax = 100,
enlarge x limits=0.25,
legend cell align=left,
legend style={
at={(1,1.05)},
anchor=south east,
column sep=1ex
}
]
\addplot coordinates {
(1, 68) (2, 70) (3, 67) (4, 67)
};
\addplot coordinates {
(1, 68) (2, 70) (3, 70) (4, 68)
};
\legend{unmodified, modified}
\end{axis}
\end{tikzpicture}
}
\subfigure{
\begin{tikzpicture}
\begin{axis}[
ybar=0pt,
scale = 0.6,
/pgf/number format/1000 sep={},
xticklabels={Bayes, Tree, kNN, SVM},
xtick = {1,2,3,4,5},
ymin = 0,
ymax = 100,
enlarge x limits=0.25,
legend cell align=left,
legend style={
at={(1,1.05)},
anchor=south east,
column sep=1ex
}
]
\addplot coordinates {
(1, 69) (2, 67) (3, 72) (4, 68)
};
\addplot coordinates {
(1, 70) (2, 70) (3, 73) (4, 69)
};
\legend{unmodified, modified}
\end{axis}
\end{tikzpicture}
}
\caption{Genuineness}
\end{figure}
我该如何修复它并在一行中显示所有的图?
编辑感谢 @percusse,问题出在空行上。现在看起来没问题了。
答案1
您应该避免subfigure
使用已经过时 15 年以上的东西:
\usepackage[caption=false]{subfig}
是您应该拨打的电话。
我不确定你需要子浮点数做什么,因为你不使用子标题。所以我将添加空的子标题来获取字母。
笔记:
- 你不应该在你想要并排的子浮点数之间有空行
tikzpicture
环境中不应该有空行- 这个特殊的例子最终会以一条过满的线结束,所以我把第三个子图留在了另外两个子图下面(只添加了一个空行
\documentclass{llncs}
\usepackage[caption=false]{subfig}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{figure}
\centering
\subfloat[]{%
\begin{tikzpicture}
\begin{axis}[
ybar = 0pt,
scale = 0.6,
/pgf/number format/1000 sep={},
xticklabels={Bayes, Tree, kNN, SVM},
xtick = {1,2,3,4,5},
ymin = 0,
ymax = 100,
enlarge x limits=0.25,
legend cell align=left,
legend style={
at={(1,1.05)},
anchor=south east,
column sep=1ex
}
]
\addplot coordinates {
(1, 68) (2, 70) (3, 67) (4, 66)
};
\addplot coordinates {
(1, 70) (2, 71) (3, 72) (4, 68)
};
\legend{unmodified, modified}
\end{axis}
\end{tikzpicture}%
}
\subfloat[]{%
\begin{tikzpicture}
\begin{axis}[
ybar=0pt,
scale = 0.6,
/pgf/number format/1000 sep={},
xticklabels={Bayes, Tree, kNN, SVM},
xtick = {1,2,3,4,5},
ymin = 0,
ymax = 100,
enlarge x limits=0.25,
legend cell align=left,
legend style={
at={(1,1.05)},
anchor=south east,
column sep=1ex
}
]
\addplot coordinates {
(1, 68) (2, 70) (3, 67) (4, 67)
};
\addplot coordinates {
(1, 68) (2, 70) (3, 70) (4, 68)
};
\legend{unmodified, modified}
\end{axis}
\end{tikzpicture}%
}
\subfloat[]{%
\begin{tikzpicture}
\begin{axis}[
ybar=0pt,
scale = 0.6,
/pgf/number format/1000 sep={},
xticklabels={Bayes, Tree, kNN, SVM},
xtick = {1,2,3,4,5},
ymin = 0,
ymax = 100,
enlarge x limits=0.25,
legend cell align=left,
legend style={
at={(1,1.05)},
anchor=south east,
column sep=1ex
}
]
\addplot coordinates {
(1, 69) (2, 67) (3, 72) (4, 68)
};
\addplot coordinates {
(1, 70) (2, 70) (3, 73) (4, 69)
};
\legend{unmodified, modified}
\end{axis}
\end{tikzpicture}
}
\caption{Genuineness}
\end{figure}
\end{document}