![相邻图中的 x 轴未对齐](https://linux22.com/image/457677/%E7%9B%B8%E9%82%BB%E5%9B%BE%E4%B8%AD%E7%9A%84%20x%20%E8%BD%B4%E6%9C%AA%E5%AF%B9%E9%BD%90.png)
我尝试对齐这两个图的 x 轴,但没有成功。我想知道哪里出了问题?
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz, pgfplots}
\pgfplotsset{compat=1.18,width=7cm}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel={$t$},
ylabel={$f(t)$},
axis lines=center,
xmin=0,xmax=5,
ymin=0,ymax=1.5,
ytick={0.368,1},
xtick={1},
xticklabels={$\dfrac{1}{\lambda}$},
yticklabels={$\dfrac{\lambda}{e}$,$\lambda$}
]
\addplot +[mark=none,smooth] {e^(-x)};
\draw [dashed] (0,0.368) -| (1,0);
\end{axis}
\end{tikzpicture}
\hspace{2cm}
\begin{tikzpicture}
\begin{axis}[
xlabel={$t$},
ylabel={$\lambda(t)$},
axis lines=center,
xmin=0,xmax=5,
ymin=0,ymax=1.5,
ytick={1},
xtick={},
xticklabels={},
yticklabels={$\lambda$}
]
\addplot +[mark=none,smooth] {1};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
我添加了[baseline]
两者,\begin{tikzpicture}
现在看起来是这样\begin{tikzpicture}[baseline]
。它解决了问题。