2

When using groupplots and setting zmin and/or zmax in the groupplot environment manually, pgfplots generates a (broken) 3d legend:

Issue

I assume the issue is that groupplot passes the zmin/zmax settings to the colorbar axis environment as well, resulting in the existential crisis making the colorbar 3d.

Omitting the settings from the global groupplot environment and passing them manually to each \nextgroupplot works. But I thought this was still worth posting in case there's a better solution or in case this is a bug that needs to be resolved.

MWE:

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{groupplots}

\begin{document}
\begin{tikzpicture}

  \begin{groupplot}[%
    group style={
      group size=2 by 1,
      horizontal sep=2cm,
    },
    zmin=-10,
    zmax=10,
    colorbar horizontal,
  ]

    \nextgroupplot
    % \nextgroupplot[zmin=-10,zmax=10] % Works if global zmin/zmax are commented out.
      \addplot3[surf] {x+y};

    \nextgroupplot
    % \nextgroupplot[zmin=-10,zmax=10] % Works if global zmin/zmax are commented out.
      \addplot3[surf] {x+y};

  \end{groupplot}
\end{tikzpicture}
\end{document}
2

You are right, the options are not reset for colorbar.

I have fixed this in pgfplots. You can activate the fix in your tex files by means of

\pgfplotsset{
    every colorbar global/.append style={
        zmin=,zmax=,
    }
}

Adding this to your preamble leads to

enter image description here

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.