pgfplots 中子图的对齐

pgfplots 中子图的对齐

我想将一个较大的图形与两个较小的子图对齐,这两个子图应具有相同的大小并到达主图形的below south eastbelow south west锚点。下面的示例不起作用,因为我无法为twothree轴提供两种不同的对齐方式:

\documentclass{standalone}

\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
  \begin{axis}[name=one, width=20cm, height=8cm]
  \end{axis}
  \begin{axis}[name=two,
    at=(one.below south), anchor=above north east
    ]
  \end{axis}
  \begin{axis}[name=three,
    at=(one.below south), anchor=above north west,
    yticklabel pos=right,
    ]
  \end{axis}
\end{tikzpicture}

\end{document}

enter image description here

如何将下面的数字延伸到one.below south匹配和one.below south west匹配?我认为找到第一个图中横轴的长度也会有所帮助,但我不知道如何获得或定义这个长度。two.above north westone.below south eastthree.above north east

答案1

通过设置scale only axiswidth指定轴的宽度(而不是带有标签的整体图)。这样,您可以将较小图的宽度精确设置为主图宽度的一半:

\documentclass[border=5mm]{standalone}

\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
  \begin{axis}[name=one, width=10cm, height=4cm, scale only axis]
  \end{axis}
  \begin{axis}[name=two,
    width=5cm, height=4cm, scale only axis,
    at=(one.below south), anchor=above north east
    ]
  \end{axis}
  \begin{axis}[name=three,
    width=5cm, height=4cm, scale only axis,
    at=(one.below south), anchor=above north west,
    yticklabel pos=right,
    ]
  \end{axis}
\end{tikzpicture}

\end{document}

相关内容