我正在努力将三个图表并排放在一行中。我找到的每个解决方案都因使用轴而导致错误。
\begin{tikzpicture}
\begin{axis}[
domain=-10:10,
grid=major,
xmin=-10, xmax=10,
ymin=-10, ymax=10,
xlabel={x}, ylabel={y},
samples=1000,
axis y line=center,
axis x line=middle
]
\addplot+[mark=none,color=blue] {1 * abs(x-1) + 0};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
domain=-10:10,
grid=major,
xmin=-10, xmax=10,
ymin=-10, ymax=10,
xlabel={x}, ylabel={y},
samples=1000,
axis y line=center,
axis x line=middle
]
\addplot+[mark=none,color=red] {1 * abs(x-0) + 0};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
domain=-10:10,
grid=major,
xmin=-10, xmax=10,
ymin=-10, ymax=10,
xlabel={x}, ylabel={y},
samples=1000,
axis y line=center,
axis x line=middle
]
\addplot+[mark=none,color=green] {1 * abs(x+1) + 0};
\end{axis}
\end{tikzpicture}
我想将这三张图片并排放在一行中,包括每张图片的标题 + 整个图片的标题。我对图片和子图等进行了很多尝试,但总是收到错误消息,告诉我由于部分原因出现了问题\begin{axis}
。这就是我希望它看起来的样子:
编辑:@martijnn2008 回复你的评论
我刚刚尝试过:并排放置图片时的标题问题-但它不起作用。
\begin{figure}
\centering
\begin{minipage}[t]{.45\textwidth}
\centering
\resizebox{0.2\textwidth}{!}{
\begin{tikzpicture}
\begin{axis}[
domain=-10:10,
grid=major,
xmin=-10, xmax=10,
ymin=-10, ymax=10,
xlabel={x}, ylabel={y},
samples=1000,
axis y line=center,
axis x line=middle
]
\addplot+[mark=none,color=blue] {1 * abs(x-0) + 0};
\end{axis}
\end{tikzpicture}
}
\caption{A not.}
\end{minipage}\hfill
\begin{minipage}[t]{.45\textwidth}
\centering
\resizebox{0.2\textwidth}{!}{
\begin{tikzpicture}
\begin{axis}[
domain=-10:10,
grid=major,
xmin=-10, xmax=10,
ymin=-10, ymax=10,
xlabel={x}, ylabel={y},
samples=1000,
axis y line=center,
axis x line=middle
]
\addplot+[mark=none,color=blue] {1 * abs(x-0) + 0};
\end{axis}
\end{tikzpicture}
}
\caption{A caption.}
\end{minipage}
\caption{Lorem Ipsum dolor sit atmet.}
\end{figure}
如图所示,两个图表仍然不在一行上。但我们现在有了标题。
答案1
非常感谢@martijnn2008 和@cmhughes!以下是解决方案:
\begin{figure}
\centering
\begin{minipage}[t]{.50\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
domain=-10:10,
grid=major,
xmin=-10, xmax=10,
ymin=-10, ymax=10,
xlabel={x}, ylabel={y},
samples=1000,
axis y line=center,
axis x line=middle
]
\addplot+[mark=none,color=blue] {1 * abs(x-0) + 0};
\end{axis}
\end{tikzpicture}
\caption{$h=0$}
\end{minipage}\hfill
\begin{minipage}[t]{.50\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
domain=-10:10,
grid=major,
xmin=-10, xmax=10,
ymin=-10, ymax=10,
xlabel={x}, ylabel={y},
samples=1000,
axis y line=center,
axis x line=middle
]
\addplot+[mark=none,color=red] {1 * abs(x-1) + 0};
\end{axis}
\end{tikzpicture}
\caption{$h=1$}
\end{minipage}
\caption{$\forall a, h, k \in \mathbb{R}, f(x) = a \mid x-h \mid + k$}
\end{figure}