Então, tenho trabalhado em uma resposta paraessa questãoe trabalhei na adaptação para groupplots, ou seja, colocando automaticamente legenda na margem externa, marcas de eixo e rótulos na parte interna. Estou enfrentando dois problemas com o mwe a partir de então:
- Como ativar/desativar a etiqueta do eixo de forma inteligente de acordo com o lado? Uma maneira possível é outro uso de \ifoddpage, mas não é bonito, eu acho. Posso ter esquecido algo do manual.
- Como usar
trim axis group left/right
junto com o posicionamento da legenda proposto por Jake emessa questão? Ao recortar eixos, a legenda é colocada com as posições anteriores, não exatamente com os resultados esperados...
Aqui está o arquivo principal:
\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\usepackage{float}
\usepackage{ifoddpage}
\begin{document}
\begin{figure}[H]
\input{groupplot}
\caption{first figure}
\end{figure}
\newpage
\begin{figure}[H]
\input{groupplot}
\caption{first figure}
\end{figure}
\end{document}
E aqui está a groupplot.tex
figura:
\checkoddpage
\ifoddpage
\def\yticksside{ edge right}
\else
\def\yticksside{ edge left}
\fi
\centering
\begin{tikzpicture}%[trim axis group left,trim axis group right]
\begin{groupplot}[
group style = {
group size = 2 by 1,
horizontal sep=0mm,
yticklabels at=\yticksside,
},
width=0.5\columnwidth,
ylabel={$y$label},
]
\nextgroupplot[
xlabel={$x$},
legend to name=grouplegend,
ylabel near ticks,
]
\addplot coordinates { (0,0) (1,1) };
\addlegendentry{Legend entry}
\nextgroupplot[
xlabel={$x$},
ylabel near ticks,
]
\addplot coordinates { (0,0) (1,1) };
\end{groupplot}
\checkoddpage
\ifoddpage
\def\legendpos{group c1r1.south west}
\def\legendanchor{north east}
\else
\def\legendpos{group c2r1.south east}
\def\legendanchor{north west}
\fi
\node at (\legendpos) [anchor=\legendanchor] {\ref{grouplegend}};
\end{tikzpicture}