4

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:

enter image description here

I want to draw something like this:

enter image description here

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.
tikzlearner
  • 4,527

1 Answers1

2

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}
\pgfplotsset{width=5cm,compat=newest,every axis legend/.append style={at={(0.5,1.35)}, anchor=south}}
\begin{document}

\begin{figure}
  \centering
  \subfloat[Iteration Domain for a Tile]{
      \begin{tikzpicture}
        \begin{axis}[title=Title]
        \addplot {x};
        \addlegendentry{Legend a}
        \end{axis}
      \end{tikzpicture}
  }
  \subfloat[Convex Bounding Boxes]{
      \begin{tikzpicture}
        \begin{axis}[
        title style={at={(1.17,1)},overlay},
        title=Shared title
        ]
        \addplot [color=red,mark=o]{x^2};
        \addlegendentry{Legend b}
        \end{axis}
      \end{tikzpicture}
  }
  \subfloat[Disjoint Bounding Boxes]{
      \begin{tikzpicture}
        \begin{axis}
        \addplot[color=black,mark=+] {x^3};
        \addlegendentry{Legend c}
        \end{axis}
      \end{tikzpicture}
  }
  \caption{Bounding boxes for disjoint union of data regions}
\end{figure}
\end{document}

enter image description here

erik
  • 12,673