# How to manually draw horizontal legend and place it correctly in tikz?

This is my tikz code to draw some plots.

\documentclass{article}
\usepackage{tikz,subfig}
\begin{document}

\begin{figure}
\centering
\subfloat[Iteration Domain for a Tile]{
\begin{tikzpicture}
\draw (0,0) rectangle (3.8,3.8);
\end{tikzpicture}
}
\subfloat[Convex Bounding Boxes]{
\begin{tikzpicture}
\draw (0,0) rectangle (3.8,3.8);
\end{tikzpicture}
}
\subfloat[Disjoint Bounding Boxes]{
\begin{tikzpicture}
\draw (0,0) rectangle (3.8,3.8);
\end{tikzpicture}
}
\caption{Bounding boxes for disjoint union of data regions}
\end{figure}

\end{document}


And this is the output:

I want to draw something like this:

How do I do it?

There are mainly two things:

1. I want to put legend at the top.
2. I want to put some description for (a) and some description for both (b) and (c) as shown in above figure.
-
Please change your LWE (Large Working Example) to a MWE (Minimal Working Example). It will help answerers a lot more. Kind regards –  zeroth Mar 8 '13 at 9:27
I have tried and minimized the code. –  tikzlearner Mar 8 '13 at 11:18
Great, however, still your problem seems to be about placement of text above your figures, hence for this you do not need any other things a MWE for your figures could equally be: \begin{tikzpicture}\draw (0,0) rectangle (4,4);\end{tikzpicture}. By using that MWE you can still remove many preamble lines (and also, listings is not used, so that should also be removed). –  zeroth Mar 8 '13 at 11:47
Please see how I would have done your MWE. It doesn't get any (it could, but...) shorter than this. Remember that this will help clarify your problem. –  zeroth Mar 8 '13 at 13:44

Placing the legend on top can be done using the pgfplots package, but the shared title for (b) and (c) is a little hackish (i.e., positioning is manual). I was able to come up with the following.

\documentclass{article}
\usepackage{tikz,subfig}
\usepackage{pgfplots}
\begin{document}

\begin{figure}
\centering
\subfloat[Iteration Domain for a Tile]{
\begin{tikzpicture}
\begin{axis}[title=Title]
\end{axis}
\end{tikzpicture}
}
\subfloat[Convex Bounding Boxes]{
\begin{tikzpicture}
\begin{axis}[
title style={at={(1.17,1)},overlay},
title=Shared title
]
\end{axis}
\end{tikzpicture}
}
\subfloat[Disjoint Bounding Boxes]{
\begin{tikzpicture}
\begin{axis}