[Tex/LaTex] No tick labels and adding title to groupplot generated plots

pgfplotstikz-pgf

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?

Best Answer

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