Drawing arrow with text using TikZ

I made some matrices with TikZ, but I also would like to show that the second one is a focus over a sub matrix of the first one (I made an ugly example with PS here) and to add an arrow with a text above it, as the image below shows:

This is my code so far. And this is what I achieve:

I would like to know how to do the "focus" thing and how to change the "bootstrap" label size. Also, I would like to know if it possible to do this and put (a), (b) and (c) labels for each matrix and if I can change the color of the text of an specific matrix. This my first time using TikZ, so this may be a stupid question.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,backgrounds}
\begin{document}
\begin{tikzpicture}
\matrix(A) [matrix of math nodes,%
left delimiter  = |,%
right delimiter = |] at (0,0)
{
a & b & c & d \\
e & f & g & h \\
i & j & l & m \\
n &     o & p & q \\
};
\begin{scope}[on background layer]
\fill[blue!30,opacity=.5] (A-1-1.west|-A-1-3.north) rectangle (A-3-3.south east);
\end{scope}

\matrix(B) [matrix of math nodes,%
left delimiter  = |,%
right delimiter = |] at (3.1cm,0)
{
a & b & c \\
e & f & g \\
i & j & l \\
};

\matrix(C) [matrix of math nodes,%
left delimiter  = |,%
right delimiter = |] at (6cm,0cm)
{
l & l & c \\
f & j & i \\
g & b & e \\
};

\matrix(D) [matrix of math nodes,%
left delimiter  = |,%
right delimiter = |] at (0cm,-2.5cm)
{
l & l & c \\
f & j & i \\
g & b & e \\
};

\matrix(K) [matrix of math nodes] at (0cm,-2.5cm)
{
k_{1} & k_{2} & k_{3} \\
k_{4} & k_{5} & k_{6} \\
k_{7} & k_{8} & k_{9} \\
};

\draw[->,thick] (B) -- (C) node [pos=0.66,above] {bootstrap};
\end{tikzpicture}
\end{document}


• To change the font size of bootstrap you can add font=\footnotesize to the node options.

• You can add a node above a matrix by loading the positioning library and saying e.g.

\node (a) [above=0.1cm of A] {($a$)};


If you do the same for B and C they will be a little bit lower than the a-label, because the top of those matrices is lower. You could modify the length, but it's easier to use

\node at (a-|B.north) {($b$)};


which places this node at the same x-coordinate as B.north and the same y-coordinate as a (defined above).

• A brace similar to the one in your sketch can be created by adding the decorations.pathreplacing library, and using decoration={brace,amplitude=8},decorate. You can modify the amplitude. I also added an additional arrow leading to the next matrix. I don't know exactly how you wanted this though, please comment if you want any changes.

• Adding a colour name to the matrix options will set the colour of all the nodes in the matrix, or you could add settings for all the nodes in the matrix with every node/.append style={blue} (again, added to the matrix options).

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,backgrounds,decorations.pathreplacing,positioning}
\begin{document}
\begin{tikzpicture}[decoration={brace,amplitude=10}]
\matrix(A) [matrix of math nodes,%
left delimiter  = |,%
right delimiter = |] at (0,0)
{
a & b & c & d \\
e & f & g & h \\
i & j & l & m \\
n &     o & p & q \\
};
\begin{scope}[on background layer]
\fill[blue!30,opacity=.5] (A-1-1.west|-A-1-3.north) rectangle (A-3-3.south east);
\end{scope}

\matrix(B) [matrix of math nodes,%
left delimiter  = |,%
right delimiter = |] at (3.1cm,0)
{
a & b & c \\
e & f & g \\
i & j & l \\
};

\matrix(C) [matrix of math nodes,%
left delimiter  = |,%
right delimiter = |,
every node/.append style={blue} % <-- added
] at (6cm,0cm)
{
l & l & c \\
f & j & i \\
g & b & e \\
};

\draw [decorate,thick, red] (A-1-3.north east) -- (A-3-3.south east);
\draw [thick, red, -latex](A-2-3.east) ++(0.32cm,0) to[out=0,in=180] ([xshift=-.2cm]B.west);
\draw[->,thick] (B) -- (C) node [pos=0.66,above,font=\footnotesize] {bootstrap};

\node (a) [above=2pt of A] {($a$)};
\node at (a-|B.north) {($b$)};
\node at (a-|C.north) {($c$)};
\end{tikzpicture}
\end{document}

• Just one more question: can I change the thickness of the brace to be like the arrow that has the label "bootstrap", i.e., much more thin? Thank you. – pceccon Apr 10 '14 at 20:46
• @pceccon Of course. You'll notice that I added ultra thick as an option to the brace, and very thick to the arrow pointing from the brace. The bootstrap arrow has just thick, so if you remove ultra and very all those three should have the same thickness. – Torbjørn T. Apr 10 '14 at 20:48