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}
Thank you in advance.
Best Answer
To change the font size of
bootstrap
you can addfont=\footnotesize
to the node options.You can add a node above a matrix by loading the
positioning
library and saying e.g.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
which places this node at the same x-coordinate as
B.north
and the same y-coordinate asa
(defined above).A brace similar to the one in your sketch can be created by adding the
decorations.pathreplacing
library, and usingdecoration={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 thematrix
withevery node/.append style={blue}
(again, added to thematrix
options).