6

I am generating an array of plots using pgfplots and more specifically the groupplot environment. Here is an example:

\begin{tikzpicture} 

\begin{groupplot}[group style={group size=2 by 2,horizontal sep=0.2cm,vertical sep=0.2cm},height=3cm,width=3cm] 
\nextgroupplot \addplot coordinates {(0,2) (1,1) (2,1)};
\nextgroupplot \addplot coordinates {(0,2) (1,1) (1,0)}; 
\nextgroupplot \addplot coordinates {(0,0) (1,1) (2,2)};
\nextgroupplot \addplot coordinates {(0,2) (1,1) (2,0)};
\end{groupplot}

\end{tikzpicture}

I would like to be able to eliminate either the x or the y tick labels or both. I also want to add a different title to each plot. I have not found a way to do this in the documentation. Any ideas?

7

For the tick labels, you have the xticklabels at and xticklabels at keys for group style.

For the titles, you can pass the title=<text> option to \nextgroupplot.

A little complete example:

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

\begin{document}   

\begin{tikzpicture} 

\begin{groupplot}[
group style={
  group size=2 by 2,
  horizontal sep=0.2cm,
  vertical sep=0.8cm,
  xticklabels at=edge bottom,
  yticklabels at=edge right
  },
height=3cm,
width=3cm,
] 
\nextgroupplot[title=Plot A]
  \addplot coordinates {(0,2) (1,1) (2,1)};
\nextgroupplot[title=Plot B]
  \addplot coordinates {(0,2) (1,1) (1,0)}; 
\nextgroupplot[title=Plot C]
  \addplot coordinates {(0,0) (1,1) (2,2)};
\nextgroupplot[title=Plot D]
  \addplot coordinates {(0,2) (1,1) (2,0)};
\end{groupplot}

\end{tikzpicture}

\end{document}

enter image description here

  • If I want to get rid of the labels in every plot, I see I can use the command \nextgroupplot[title=Plot 11,xticklabels={,,},yticklabels={,,}] \addplot coordinates {(0,2) (1,1) (2,1)};. I'm wondering if there is a way to avoid adding xticklabels={,,},yticklabels={,,} to every plot. I tried moving that to the group style but that did not work. – Arrigo Aug 21 '13 at 17:37

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.