0

What do I have to set so that an addplot in a groupplot is as wide as the two bottom ones; and the y-axes lie on a line.

enter image description here

\documentclass[tikz, margin=5mm]{standalone}
%\documentclass[a4paper]{article}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\pgfplotsset{compat=1.9}
\begin{document}

\begin{tikzpicture}

\pgfmathsetlengthmacro\w{3cm}
\pgfmathsetlengthmacro\h{2cm}
\pgfmathsetlengthmacro\vsep{5mm}  
\pgfmathsetlengthmacro\hsep{10mm}  

\begin{groupplot}[
group style={
  group size=2 by 2,
  vertical sep=\vsep,
  horizontal sep=\hsep,
},
height=\h,
width=\w,
scale only axis,
]

\nextgroupplot[width=\w+\hsep]
\addplot [blue, 
] {x^2};

\nextgroupplot[group/empty plot]

\nextgroupplot
\addplot[red] {x^3};

\nextgroupplot
\addplot[cyan] {x^4};
\end{groupplot}
\end{tikzpicture}
\end{document}
0

1 Answer 1

1

This uses three axis environment, using yshift and xshift to align them. Interestingly, putting a group plot into a savebox is not allowed (something about prevdepth).

\documentclass[tikz, margin=5mm]{standalone}
%\documentclass[a4paper]{article}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\pgfplotsset{compat=1.9}

\begin{document}

\pgfmathsetlengthmacro\w{3cm}
\pgfmathsetlengthmacro\h{2cm}
\pgfmathsetlengthmacro\vsep{5mm}  
\pgfmathsetlengthmacro\hsep{10mm}  

\begin{tikzpicture}

\begin{axis}[scale only axis,
  width={2*\w+\hsep},
  height=\h]
\addplot [blue] {x*x};% never use ^ for computation
\end{axis}

\begin{axis}[yshift={-\h-\vsep},
  scale only axis,
  width=\w,
  height=\h]
\addplot[red] {x*x*x};
\end{axis}

\begin{axis}[yshift={-\h-\vsep},
  xshift={\w+\hsep},
  scale only axis,
  width=\w,
  height=\h]
\addplot[cyan] {x*x*x*x};
\end{axis}

%\draw[red] (current bounding box.south west) rectangle (current bounding box.north east);
\end{tikzpicture}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .