我正在使用此代码将两个 TikZ 图形放在一行上:
\documentclass{book}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{float}
\usepackage{subcaption}
\pgfplotsset{compat=1.16}
\tikzset{declare function={gauss(\x,\y,\z)=
1/(\z*sqrt(2*pi))*exp(-((\x-\y)^2)/(2*\z^2));}}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes}
\usetikzlibrary{arrows}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}
\begin{figure}[ht]
\centering
\begin{subfigure}{0.45\textwidth}
\centering
\include{./figures/HypothesisTestingTwoTailed}
\caption{two-tailed test}
\label{fig:OneAndTwoTailedTests-Two}
\end{subfigure}
\quad
\begin{subfigure}{0.45\textwidth}
\centering
\include{./figures/HypothesisTestingOneTailed}
\caption{one-tailed test}
\label{fig:OneAndTwoTailedTests-One}
\end{subfigure}\\
\caption{One- and two-tailed tests}
\label{fig:OneAndTwoTailedTests}
\end{figure}
\end{document}
结果如下:
这是其中一张图片:
\begin{tikzpicture}
\begin{axis}[%
no markers,
domain=-3:3,
height=4cm, width=7cm,
samples=61, smooth,
axis x line=bottom,
axis y line=none,
xtick=\empty, ytick=\empty,
clip=false,
enlargelimits=upper
]
\node [coordinate] at (axis cs:0,0) (origin) {};
\node [coordinate] at (axis cs:-2.5,0) (alphaleft) {};
\node [coordinate] at (axis cs:2.5,0) (alpharight) {};
\node[coordinate] (zleft) at (axis cs:-2,{gauss(-2,0,1)}) {};
\draw (axis cs:-2,0) -- (zleft);
\node[coordinate] (zright) at (axis cs:2,{gauss(2,0,1)}) {};
\draw (axis cs:2,0) -- (zright);
\addplot [thick] {gauss(x,0,1)};
\node[coordinate] (top) at (axis cs:0,{gauss(0,0,1)}) {};
\draw [dashed] (axis cs:0,0) -- (top);
\node [below = 1mm of origin] {$\mu$};
\node [below = 1mm of alphaleft, anchor=north] {$\alpha/2$};
\node [below = 1mm of alpharight, anchor=north] {$\alpha/2$};
\end{axis}
\end{tikzpicture}
唯一的区别应该是左图中的“a/2”,由于“/”的原因,它比“a”高。
我想让两个水平轴对齐。我更愿意处理图片大小,而不是使用子浮点的对齐选项。我正在寻找一种方法来设置绘图周围(具体来说,是下方)的填充,以便两张图片的填充相同,这将使它们正确对齐。我要添加第三张图片,并在其中两张图片下方添加一些内容,所以我认为设置填充是获得正确对齐的最佳方法。这可能吗?
谢谢你!