# grouping options problem in pgfplots.groupplots when also using units library

I have a problem with the grouping options of pgfplots.groupplots. Besides the labels I have also units defined. With the option xlabels at=edge bottom only the label, but not the unit is moved to the bottom of the group (same with ylabels).

\pgfplotsset{
use units,
x unit=s, x unit prefix={}, % 5.3.1 p227
xlabel=time,
ylabel=frequency $\omega$,
}

\begin{groupplot}[
group style={
group name=my plots,
group size=2 by 2,
xlabels at=edge bottom,
ylabels at=edge left,
},


Any ideas how to put also the unit to the bottom?

-

Edit: Simple solution: If you just need to get this working and don't want to fiddle with the library code, you can just switch off the units for individual plots by using \nextgroupplot [x unit={}] or y unit={} or both, depending on which plot is next.

"Proper" Solution: It seems like these two libraries are just not aware of each other, so you'll have to make some adjustments to the groupplots code. The labels are set right in the main chunk of code, unfortunately, so you can't get away with just redefining some small macros.

In the file tikzlibrarypgfplots.groupplots.code.tex you have to replace the two occurrences of the line

\pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/xlabel={}}}%


with

\pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/xlabel={}}%
\ifpgfplots@units@use
\pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/x unit={}}
\fi}%


and the two occurrences of the line

\pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/ylabel={}}}%


with

\pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/ylabel={}}%
\ifpgfplots@units@use
\pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/y unit={}}
\fi}%


This will work with or without the units library, and with all combinations of edge bottom, edge top, edge left, and edge right.

Here's an example of the behaviour of the modified library:

\documentclass{minimal}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots,units}

\begin{document}
\begin{tikzpicture}

\pgfplotsset{
use units,
x unit=s, x unit prefix={}, % 5.3.1 p227
y unit=m, y unit prefix=k,
xlabel=time,
ylabel=frequency $\omega$,
}

\begin{groupplot}[
group style={
group name=my plots,
group size=2 by 2,
xlabels at=edge bottom,
ylabels at=edge left
},height=4cm, width=4cm]
\nextgroupplot
\nextgroupplot
\nextgroupplot
\nextgroupplot

@riddleculous: Sorry, there was an error in my answer, the correct file name is tikzlibrarypgfplots.groupplots.code.tex. For getting this incorporated into PGFPlots, you could open a feature request – Jake Apr 3 at 21:24