我尝试对齐这两个图的 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]
。它解决了问题。