在处理多张图片时,我总是遇到对齐问题。目前,我的问题如下图所示。
可以看出,第一幅图像与其他两幅图像没有对齐。我尝试了几种技巧,但都没有奏效。所以,我洗耳恭听。生成图像的代码是:
\begin{figure}[!htb]
\centering
\begin{tikzpicture}
\begin{axis}[
xmin=0,xmax=6,
ymin=-2,ymax=6,
width=7.5cm, height=5.5cm,
grid,% <-- changed
grid style={line width=.1pt, draw=white},
clip mode=individual,
xtick=\empty,
ytick=\empty,
legend style={at={(1.25,0.98)},anchor=north east},
%hide axis,
%hide y axis,
]
\addplot[only marks,
mark options={scale=1.5, fill=white},
mark size=2pt,
color=black,
%opacity=0.8,
fill opacity = 0.2,
]
table [x={x}, y={y}, col sep=comma] {csv/more/cloudall_5.csv};
\addplot[only marks,
mark options={scale=1.5, fill=white},
mark size=2pt,
color=blue,
%opacity=0.8,
fill opacity = 0.2,
]
table [x={x}, y={y}, col sep=comma] {csv/more/cloud_5.csv};
\addplot[color=red,
domain=-1:8,
line width=0.5mm,
]
{
0.0421120183297*x +1.07550170479
};
\addplot[color=red,
domain=-1:8,
line width=0.5mm,
]
{
0.201422124812*x -1.65615183388
};
\addplot[color=blue,
domain=-1:8,
line width=0.5mm,
]
{
0.0605449027383*x -0.0877091819259
};
\addplot[dashed,
color=black,
domain=-1:8,
line width=0.25mm,
]
{
0.121010298828*x -0.277350636346
};
%\legend{ ,$RANSAC$,$MQ$,$ME$}
\end{axis}
\end{tikzpicture}%
\begin{tikzpicture}
\begin{axis}[
xmin=0,xmax=6,
ymin=-2,ymax=6,
width=7.5cm, height=5.5cm,
grid,% <-- changed
grid style={line width=.1pt, draw=white},
clip mode=individual,
xtick=\empty,
ytick=\empty,
legend style={at={(1.25,0.98)},anchor=north east},
%hide axis,
%hide y axis,
]
\addplot[only marks,
mark options={scale=1.5, fill=white},
mark size=2pt,
color=black,
%opacity=0.8,
fill opacity = 0.2,
]
table [x={x}, y={y}, col sep=comma] {csv/more/cloudall_15.csv};
\addplot[only marks,
mark options={scale=1.5, fill=white},
mark size=2pt,
color=blue,
%opacity=0.8,
fill opacity = 0.2,
]
table [x={x}, y={y}, col sep=comma] {csv/more/cloud_15.csv};
\addplot[color=red,
domain=-1:8,
line width=0.5mm,
]
{
-0.464299252633*x +2.83110734717
};
\addplot[color=red,
domain=-1:8,
line width=0.5mm,
]
{
0.335246577615*x -1.37932758104
};
\addplot[color=blue,
domain=-1:8,
line width=0.5mm,
]
{
-0.0631252062184*x +0.642992901914
};
\addplot[dashed,
color=black,
domain=-1:8,
line width=0.25mm,
]
{
-0.0556622617388*x +0.679211007364
};
%\legend{ ,$RANSAC$,$MQ$,$ME$}
\end{axis}
\end{tikzpicture}%
\begin{tikzpicture}
\begin{axis}[
xmin=0,xmax=6,
ymin=-2,ymax=6,
width=7.5cm, height=5.5cm,
grid,% <-- changed
grid style={line width=.1pt, draw=white},
clip mode=individual,
xtick=\empty,
ytick=\empty,
legend style={at={(1.25,0.98)},anchor=north east},
%hide axis,
%hide y axis,
]
\addplot[only marks,
mark options={scale=1.5, fill=white},
mark size=2pt,
color=black,
%opacity=0.8,
fill opacity = 0.2,
]
table [x={x}, y={y}, col sep=comma] {csv/more/cloudall_20.csv};
\addplot[only marks,
mark options={scale=1.5, fill=white},
mark size=2pt,
color=blue,
%opacity=0.8,
fill opacity = 0.2,
]
table [x={x}, y={y}, col sep=comma] {csv/more/cloud_20.csv};
\addplot[color=red,
domain=-1:8,
line width=0.5mm,
]
{
-0.103449726719*x +1.92665749586
};
\addplot[color=red,
domain=-1:8,
line width=0.5mm,
]
{
0.0850917579094*x -1.02445254963
};
\addplot[color=blue,
domain=-1:8,
line width=0.5mm,
]
{
0.008334360454*x +0.406334090188
};
\addplot[dashed,
color=black,
domain=-1:8,
line width=0.25mm,
]
{
-0.00909812720891*x +0.449836565041
};
%\legend{ ,$RANSAC$,$MQ$,$ME$}
\end{axis}
\end{tikzpicture}%
\caption{Em preto, pontos localizados fora e, em azul, pontos localizados dentro da janela de interesse. Em vermelho, retas suportes das fileiras ajustadas por meio do RANSAC. Em tracejado, reta bissetriz associada ao par de retas suportes. Em azul, reta bissetriz filtrada (reta de refer\^{e}ncia).}
\label{resultado}
\end{figure}
答案1
实际上,它们是完全对齐的,只是不是你想要的那样。问题是,在第一个图中,您在轴外有标记,这会使图形的边界框比其他边界框更宽。因此,您需要重置边界框以至少跟随左轴。这可以通过两种方式完成,如下所示。由于您使用我没有的导入的 csv 文件,所以我制作了一个新的 MWE。由于我有两个示例,我曾经将twocolumn
它们并排放置。
第一个修复方法是添加[trim axis left]
到图片(或轴)中。这意味着轴左侧的所有内容都不被视为边界框。我认为这比下面的第二个解决方案更新,但我还认为我在图中看到了一个小的错位。上部略微偏向下部。它几乎看不见,我不确定打印时它是否真的在那里(我没有尝试过)。
第二个修复方法更直接。绘图后重置边界框并将其设置为轴的大小。
\documentclass[twocolumn]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\begin{document}
\section*{First fix}
\begin{tikzpicture}[trim axis left]
\begin{axis}[%
xmin=0,xmax=6,ymin=-2,ymax=6,
width=7.5cm, height=5.5cm,
xtick=\empty,
ytick=\empty,
]
\addplot[only marks,mark options={scale=1.5, fill=white},mark size=2pt,color=black,fill opacity = 0.2]
coordinates {(0,1) (1,0.5) (2,0.75) (3,0)};
\end{axis}
\end{tikzpicture}
\newline
\begin{tikzpicture}
\begin{axis}[%
xmin=0,xmax=6,ymin=-2,ymax=6,
width=7.5cm, height=5.5cm,
xtick=\empty,
ytick=\empty,
]
\addplot[only marks,mark options={scale=1.5, fill=white},mark size=2pt,color=black,fill opacity = 0.2]
coordinates {(0.5,1) (1,0.5) (2,0.75) (3,0)};
\end{axis}
\end{tikzpicture}
\newpage
\section*{Second fix}
\begin{tikzpicture}[trim axis left]
\begin{axis}[%
xmin=0,xmax=6,ymin=-2,ymax=6,
width=7.5cm, height=5.5cm,
xtick=\empty,
ytick=\empty,
]
\addplot[only marks,mark options={scale=1.5, fill=white},mark size=2pt,color=black,fill opacity = 0.2]
coordinates {(0,1) (1,0.5) (2,0.75) (3,0)};
\end{axis}
\pgfresetboundingbox
\useasboundingbox (current axis.south west) rectangle (current axis.north east);
\end{tikzpicture}
\newline
\begin{tikzpicture}
\begin{axis}[%
xmin=0,xmax=6,ymin=-2,ymax=6,
width=7.5cm, height=5.5cm,
xtick=\empty,
ytick=\empty,
]
\addplot[only marks,mark options={scale=1.5, fill=white},mark size=2pt,color=black,fill opacity = 0.2]
coordinates {(0.5,1) (1,0.5) (2,0.75) (3,0)};
\end{axis}
\pgfresetboundingbox
\useasboundingbox (current axis.south west) rectangle (current axis.north east);
\end{tikzpicture}
\end{document}