我正在使用 Ti钾Z/pgfplotsclip=false
使得我的“草图”中的对角线超出轴的范围。问题是这会产生未正确对齐的子图:
\documentclass{article}
\usepackage{subfigure}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\begin{document}
\begin{figure}
\centering
\subfigure[] {
\begin{tikzpicture}[scale=0.6]
\begin{axis}[
axis equal image,
axis lines=left,
xtick=\empty,
ytick=\empty,
xmin=0,
xmax=120,
ymin=0,
ymax=120,
clip=false,
]
\addplot[] coordinates { (-5,100) (115,100) };
\addplot[] coordinates { (100,110) (100,-5) };
\addplot[] coordinates { (55,-5) (130,105) };
\end{axis}
\end{tikzpicture}
}
\subfigure[] {
\begin{tikzpicture}[scale=0.6]
\begin{axis}[
axis equal image,
axis lines=left,
xtick=\empty,
ytick=\empty,
xmin=0,
xmax=120,
ymin=0,
ymax=120,
clip=false,
]
% constraints
\addplot[] coordinates { (-5,100) (115,100) };
\addplot[] coordinates { (100,110) (100,-25) };
\addplot[] coordinates { (90,-30) (160,70.7) };
\end{axis}
\end{tikzpicture}
}
\end{figure}
\end{document}
这里有很多关于子图对齐的帖子,但似乎没有一个能解决我的问题。例如,我尝试使用subcaption
而不是subfigure
,并将position
参数设置为t
,但这没有效果 --- 可能是边界框被 混淆了clip=false
?
答案1
您的图形已对齐 - 与图形底部对齐。如果您希望在其他地方对齐,您可以调整图形以使其大小相同。一种解决方案是确保图形大小相同,方法是使用以下选项“绘制”导致尺寸差异的线条draw=none
:
\addplot[draw=none] coordinates { (90,-30) (160,70.7) };
得出的结果是:
代码:
\documentclass{article}
\usepackage{subfigure}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\begin{document}
\begin{figure}
\centering
\subfigure[] {
\begin{tikzpicture}[scale=0.6]
\begin{axis}[
axis equal image,
axis lines=left,
xtick=\empty,
ytick=\empty,
xmin=0,
xmax=120,
ymin=0,
ymax=120,
clip=false,
]
\addplot[draw=none] coordinates { (90,-30) (160,70.7) };%% <-- Added this.
\addplot[] coordinates { (-5,100) (115,100) };
\addplot[] coordinates { (100,110) (100,-5) };
\addplot[] coordinates { (55,-5) (130,105) };
\end{axis}
\end{tikzpicture}
}
\subfigure[] {
\begin{tikzpicture}[scale=0.6]
\begin{axis}[
axis equal image,
axis lines=left,
xtick=\empty,
ytick=\empty,
xmin=0,
xmax=120,
ymin=0,
ymax=120,
clip=false,
]
% constraints
\addplot[] coordinates { (-5,100) (115,100) };
\addplot[] coordinates { (100,110) (100,-25) };
\addplot[] coordinates { (90,-30) (160,70.7) };
\end{axis}
\end{tikzpicture}
}
\end{figure}
\end{document}