2

I tried to stack my plots with a groupplot from pgfplots package. Like in this MWE:

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{units}
\usepgfplotslibrary{groupplots}

\begin{document}

\begin{tikzpicture}
\begin{groupplot}[
    group style={
        group size=1 by 3,
        vertical sep=1ex
    },
    scale only axis=true,
    height=1.5cm, width=8cm,
    ticks=none]
    \nextgroupplot[axis y line=left,axis x line=none]
    \addplot[black, domain=0:360] {sin(x)};
    \nextgroupplot[axis y line=left,axis x line=none]
    \addplot[black, domain=0:360] {cos(x)};
    \nextgroupplot[axis y line=left,axis x line=bottom,xlabel=time]
    \addplot[black, domain=0:360] {cos(x)};
\end{groupplot}
\end{tikzpicture}

\end{document}

I don't understand why the plots aren't aligned/scaled in the same way:

result/expected

How can I get my plots aligned in the same way?

2

Specifying domain does not set the xmin, xmax etc. for the plot.
It simply sets the function evaluation domain and then afterwards the min/max limits are set from the data. Due to rounding errors you can expect to see the behaviour you have.

In general:

Anytime you use groupplots and sharing axis domains you should specify x/ymin AND x/ymax.

So your code needs to look like this:

\begin{groupplot}[
   group style={
      group size=1 by 3,
      vertical sep=1ex
   },
   xmin=0,xmax=360,
   scale only axis=true,
   height=1.5cm, width=8cm,
   ticks=none]
....
  • Good to know. My real live data is now perfectly aligned! – someonr Dec 1 '13 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.