使用 pgfplots 中的 groupplot 繪製對齊圖

使用 pgfplots 中的 groupplot 繪製對齊圖

我正在使用groupplots庫來pgfplots建立繪圖分組。我使用的是 2x2 尺寸,但只有 3 張圖。如何將最右邊的圖垂直居中,形成三角形而不是上下顛倒L?在另一種情況下,我想將底部圖水平居中,這會使用相同的程序嗎?還有比 更好的工具嗎groupplots

\documentclass{standalone}
\usepackage{tikz,pgfplots}
    \usepgfplotslibrary{groupplots}

\begin{document}
  \begin{tikzpicture}
    \begin{groupplot}[
      group style={group size=2 by 2},
      width=4cm, height=4cm,
    ]
    \nextgroupplot
      \addplot coordinates{(0,0) (1,2) (2,1)};
    \nextgroupplot
      \addplot coordinates{(0,0) (1,2) (2,1)};
    \nextgroupplot
      \addplot coordinates{(0,0) (1,2) (2,1)};
    \end{groupplot}
  \end{tikzpicture}
\end{document}

答案1

感謝 Jake 的建議,我的原始解決方案的顯著壓縮是可能的(因為我對 tikz 一無所知)。此外,新版本將於stackengine本週末上市。我在這裡使用的語法在舊版本和新版本中都適用。如果需要,您可以控製圖間隔(即,正常的 hspacing 將在頂部兩個圖之間起作用,並且可選的長度參數\stackunder將定義垂直間隙)。

\documentclass{standalone}
\usepackage{stackengine}
\usepackage{tikz,pgfplots}
    \usepgfplotslibrary{groupplots}
\begin{document}
\stackunder{%
  \begin{tikzpicture}
    \begin{axis}[width=4cm, height=4cm] \addplot coordinates{%
      (0,0) (1,2) (2,1)}; \end{axis}
  \end{tikzpicture}
  \begin{tikzpicture}
    \begin{axis}[width=4cm, height=4cm] \addplot coordinates{%
      (0,0) (1,2) (2,1)}; \end{axis}
  \end{tikzpicture}
}{%
  \begin{tikzpicture}
    \begin{axis}[width=4cm, height=4cm] \addplot coordinates{%
      (0,0) (1,2) (2,1)}; \end{axis}
  \end{tikzpicture}
}
\end{document}

在此輸入影像描述

相關內容