3

I would like to put quite many small plots in a groupplot environment and provide ticklabels on all adges of the groupplot (no labels at individual plots). In the following example, I've set the labels to bottom and left. I could set them to top and right, too, but I am looking for an option called "both" or the like and could not find it. How can I print the labels on all four edges?

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\begin{document}

\begin{tikzpicture}
    \begin{groupplot}[group style={group size=2 by 2,
        horizontal sep=7pt,vertical sep=7pt,
        xticklabels at=edge bottom,
        yticklabels at=edge left},
    axis on top,
    enlargelimits=false,
    xmin=-26,xmax=26,ymin=-2,ymax=2,
    height=5cm,width=.4\textwidth]
    \nextgroupplot[]
    \addplot {sin(x)};
    \nextgroupplot[]
    \addplot {sin(x)};
    \nextgroupplot[]
    \addplot {sin(x)};
    \nextgroupplot[]
    \addplot {sin(x)};
    \end{groupplot}
\end{tikzpicture}

\end{document}

output

2

A bit more tedious, but you can set the ticklabel pos for each axis:

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\begin{document}

\begin{tikzpicture}
    \begin{groupplot}[group style={group size=2 by 2,
        horizontal sep=7pt,vertical sep=7pt},
    axis on top,
    enlargelimits=false,
    xmin=-26,xmax=26,ymin=-2,ymax=2,
    height=5cm,width=.4\textwidth]
    \nextgroupplot[xticklabel pos=right]
    \addplot {sin(x)};
    \nextgroupplot[xticklabel pos=right,yticklabel pos=right]
    \addplot {sin(x)};
    \nextgroupplot[]
    \addplot {sin(x)};
    \nextgroupplot[yticklabel pos=right]
    \addplot {sin(x)};
    \end{groupplot}
\end{tikzpicture}

\end{document}

enter image description here

  • thanks! Of course, manual positioning is a way, but if possible, I would to have some automated solution since there will be quite a few groupplots with many elements each. – riddleculous Apr 3 '16 at 16:06
  • This example does not work for me. In particular, "yticklabel pos=right" has no effect. In a 2x2 group plot, I also want to show y tick labels on the outer edges. However, I only see the y tick labels on the left 2 sub-plots, no y tick labels are shown on the right 2 sub-plots. Can someone continue to help? – Novice User Aug 4 '17 at 15:20
  • Sorry, I tried this example again. This example worked this time. The reason I failed the first time is that "y descriptions at" conflict with "yticklabels pos". Namely, if I used "y descriptions at=edge left", then "yticklabels pos=right" stops working. – Novice User Aug 4 '17 at 15:39

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.