1

When making several tikz pictures (matrices) the alignment gets fuzzy. When I make just 4, everything works, but when I create 6 the bottom two are not aligned correctly.

Could someone help me adjust this?

(In my real thesis the maps are 17X17, but this didnt fit in the question).

Example of Output

    \usepackage[center,small]{caption}
    \setlength{\captionmargin}{36pt}
    \newcommand{\legend}[1]{
        \newlength{\captiontextwidth}
        \setlength{\captiontextwidth}{\textwidth}
        \addtolength{\captiontextwidth}{-2\captionmargin}
        \vspace{0.1mm}
        \hspace{2.7mm}\parbox{\captiontextwidth}{\singlespace \small (#1)}
    }
    \usepackage{tikz}               % Used for gantt
    \usetikzlibrary{matrix}             % used for Markov Maps
    %\usepackage{gantt}             % Gantt charts
    \usepackage{pgf-pie}                % pie charts
    \usepackage{subcaption}
    \usepackage{rotating}
    \begin{document}

\begin{figure}[tb]
    \subcaptionbox{Cluster 1, $\pi_1 = 0.14$}{
    \begin{tikzpicture}[font=\ttfamily, ampersand replacement=\&]
    \matrix (A) [nodes in empty cells,
    matrix of nodes,
    nodes={draw, minimum size=3mm, inner sep=0pt, outer sep=0pt, anchor=center},
    row 1/.style={nodes={draw=none, rotate=90, anchor=west, inner xsep=1mm}},
    column 1/.style={nodes={draw=none, minimum width=30mm, text width=28mm, align=right}},
    column sep=-\pgflinewidth,
    row sep=-\pgflinewidth
    ]
    { \&    AC  \&  CH  \&  DP  \&  HP  \&  IA  \&  LB  \&  LP  \&  NL  \&  SC  \&  show\_discount\_reminder    \&  show\_funnel\_campaign  \&  show\_recc  \&  show\_recp  \&  show\_upsell    \&  show\_wijnatlas     \&  WV  \&  XT  \\
    AC  \& |[fill=black!    1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  68  ]|\& |[fill=black!  3   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  16  ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  10  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
    CH  \& |[fill=black!    1   ]|\& |[fill=black!  7   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  7   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  13  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  65  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  6   ]|\\
    DP  \& |[fill=black!    4   ]|\& |[fill=black!  0   ]|\& |[fill=black!  10  ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  75  ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\\
    HP  \& |[fill=black!    2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  9   ]|\& |[fill=black!  42  ]|\& |[fill=black!  1   ]|\& |[fill=black!  2   ]|\& |[fill=black!  15  ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  22  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  1   ]|\\
    IA  \& |[fill=black!    0   ]|\& |[fill=black!  3   ]|\& |[fill=black!  12  ]|\& |[fill=black!  9   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  35  ]|\& |[fill=black!  0   ]|\& |[fill=black!  4   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  36  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
    LB  \& |[fill=black!    5   ]|\& |[fill=black!  0   ]|\& |[fill=black!  13  ]|\& |[fill=black!  24  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  21  ]|\& |[fill=black!  0   ]|\& |[fill=black!  6   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  25  ]|\& |[fill=black!  0   ]|\& |[fill=black!  5   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
    LP  \& |[fill=black!    2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  7   ]|\& |[fill=black!  6   ]|\& |[fill=black!  1   ]|\& |[fill=black!  3   ]|\& |[fill=black!  33  ]|\& |[fill=black!  0   ]|\& |[fill=black!  4   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  20  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  20  ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\\
    NL  \& |[fill=black!    0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  30  ]|\& |[fill=black!  50  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  20  ]|\\
    SC  \& |[fill=black!    0   ]|\& |[fill=black!  7   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  13  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  73  ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\\
    show\_discount  \& |[fill=black!    4   ]|\& |[fill=black!  0   ]|\& |[fill=black!  13  ]|\& |[fill=black!  4   ]|\& |[fill=black!  4   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  17  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  52  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  4   ]|\\
    show\_funnel    \& |[fill=black!    0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  5   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  31  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  60  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\\
    };
    \end{tikzpicture}
    }
    \subcaptionbox{Cluster 2, $\pi_2 = 0.15$}{
    \begin{tikzpicture}[font=\ttfamily, ampersand replacement=\&]
    \matrix (A) [nodes in empty cells,
    matrix of nodes,
    nodes={draw, minimum size=3mm, inner sep=0pt, outer sep=0pt, anchor=center},
    row 1/.style={nodes={draw=none, rotate=90, anchor=west, inner xsep=1mm}},
    %column 1/.style={nodes={draw=none, minimum width=43mm, text width=40mm, align=right}},
    column sep=-\pgflinewidth,
    row sep=-\pgflinewidth
    ]
    { AC    \&  CH  \&  DP  \&  HP  \&  IA  \&  LB  \&  LP  \&  NL  \&  SC  \&  show\_discount\_reminder    \&  show\_funnel\_campaign  \&  show\_recc  \&  show\_recp  \&  show\_upsell    \&  show\_wijnatlas     \&  WV  \&  XT  \\
         |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  44  ]|\& |[fill=black!  7   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  40  ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  5   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
         |[fill=black!  0   ]|\& |[fill=black!  12  ]|\& |[fill=black!  1   ]|\& |[fill=black!  1   ]|\& |[fill=black!  1   ]|\& |[fill=black!  20  ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  28  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  22  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  12  ]|\\
         |[fill=black!  8   ]|\& |[fill=black!  0   ]|\& |[fill=black!  19  ]|\& |[fill=black!  2   ]|\& |[fill=black!  1   ]|\& |[fill=black!  2   ]|\& |[fill=black!  13  ]|\& |[fill=black!  0   ]|\& |[fill=black!  13  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  38  ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\\
         |[fill=black!  3   ]|\& |[fill=black!  0   ]|\& |[fill=black!  9   ]|\& |[fill=black!  39  ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\& |[fill=black!  20  ]|\& |[fill=black!  1   ]|\& |[fill=black!  6   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  17  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\\
         |[fill=black!  4   ]|\& |[fill=black!  0   ]|\& |[fill=black!  15  ]|\& |[fill=black!  10  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  13  ]|\& |[fill=black!  2   ]|\& |[fill=black!  30  ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  21  ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  2   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\\
         |[fill=black!  6   ]|\& |[fill=black!  0   ]|\& |[fill=black!  15  ]|\& |[fill=black!  21  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  29  ]|\& |[fill=black!  1   ]|\& |[fill=black!  8   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  16  ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\& |[fill=black!  1   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\\
         |[fill=black!  8   ]|\& |[fill=black!  0   ]|\& |[fill=black!  12  ]|\& |[fill=black!  5   ]|\& |[fill=black!  1   ]|\& |[fill=black!  3   ]|\& |[fill=black!  41  ]|\& |[fill=black!  0   ]|\& |[fill=black!  10  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  9   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  10  ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\\
         |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  1   ]|\& |[fill=black!  1   ]|\& |[fill=black!  1   ]|\& |[fill=black!  4   ]|\& |[fill=black!  86  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  4   ]|\\
         |[fill=black!  1   ]|\& |[fill=black!  8   ]|\& |[fill=black!  3   ]|\& |[fill=black!  1   ]|\& |[fill=black!  1   ]|\& |[fill=black!  3   ]|\& |[fill=black!  4   ]|\& |[fill=black!  0   ]|\& |[fill=black!  54  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  20  ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\\
         |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  33  ]|\& |[fill=black!  0   ]|\& |[fill=black!  11  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  33  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  22  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
         |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  4   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  4   ]|\& |[fill=black!  0   ]|\& |[fill=black!  59  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  23  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  11  ]|\\
    };
    \end{tikzpicture}
    }
    \subcaptionbox{Cluster 3, $\pi_3 = 0.33$}{
    \begin{tikzpicture}[font=\ttfamily, ampersand replacement=\&]
    \matrix (A) [nodes in empty cells,
    matrix of nodes,
    nodes={draw, minimum size=3mm, inner sep=0pt, outer sep=0pt, anchor=center},
    %row 1/.style={nodes={draw=none, rotate=90, anchor=west, inner xsep=1mm}},
    column 1/.style={nodes={draw=none, minimum width=30mm, text width=28mm, align=right}},
    column sep=-\pgflinewidth,
    row sep=-\pgflinewidth
    ]
    { AC    \& |[fill=black!    2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  31  ]|\& |[fill=black!  8   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  53  ]|\& |[fill=black!  0   ]|\& |[fill=black!  6   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
    CH  \& |[fill=black!    0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  2   ]|\& |[fill=black!  2   ]|\& |[fill=black!  23  ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  38  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  33  ]|\\
    DP  \& |[fill=black!    7   ]|\& |[fill=black!  0   ]|\& |[fill=black!  30  ]|\& |[fill=black!  4   ]|\& |[fill=black!  1   ]|\& |[fill=black!  2   ]|\& |[fill=black!  13  ]|\& |[fill=black!  0   ]|\& |[fill=black!  15  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  25  ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\\
    HP  \& |[fill=black!    5   ]|\& |[fill=black!  0   ]|\& |[fill=black!  8   ]|\& |[fill=black!  49  ]|\& |[fill=black!  1   ]|\& |[fill=black!  1   ]|\& |[fill=black!  24  ]|\& |[fill=black!  0   ]|\& |[fill=black!  7   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  4   ]|\\
    IA  \& |[fill=black!    2   ]|\& |[fill=black!  2   ]|\& |[fill=black!  19  ]|\& |[fill=black!  13  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  24  ]|\& |[fill=black!  2   ]|\& |[fill=black!  37  ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
    LB  \& |[fill=black!    5   ]|\& |[fill=black!  3   ]|\& |[fill=black!  9   ]|\& |[fill=black!  20  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  38  ]|\& |[fill=black!  0   ]|\& |[fill=black!  12  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  8   ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
    LP  \& |[fill=black!    9   ]|\& |[fill=black!  0   ]|\& |[fill=black!  11  ]|\& |[fill=black!  5   ]|\& |[fill=black!  1   ]|\& |[fill=black!  2   ]|\& |[fill=black!  52  ]|\& |[fill=black!  0   ]|\& |[fill=black!  12  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  4   ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\\
    NL  \& |[fill=black!    3   ]|\& |[fill=black!  0   ]|\& |[fill=black!  7   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  10  ]|\& |[fill=black!  13  ]|\& |[fill=black!  53  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  13  ]|\\
    SC  \& |[fill=black!    1   ]|\& |[fill=black!  10  ]|\& |[fill=black!  2   ]|\& |[fill=black!  2   ]|\& |[fill=black!  1   ]|\& |[fill=black!  3   ]|\& |[fill=black!  5   ]|\& |[fill=black!  0   ]|\& |[fill=black!  63  ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  7   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  5   ]|\\
    show\_discount  \& |[fill=black!    0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  4   ]|\& |[fill=black!  4   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  87  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  4   ]|\\
    show\_funnel    \& |[fill=black!    0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  90  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  4   ]|\\
    };
    \end{tikzpicture}
    }
    \subcaptionbox{Cluster 4, $\pi_4 = 0.10$}{
    \begin{tikzpicture}[font=\ttfamily, ampersand replacement=\&]
    \matrix (A) [nodes in empty cells,
    matrix of nodes,
    nodes={draw, minimum size=3mm, inner sep=0pt, outer sep=0pt, anchor=center},
    %row 1/.style={nodes={draw=none, rotate=90, anchor=west, inner xsep=1mm}},
    %column 1/.style={nodes={draw=none, minimum width=43mm, text width=40mm, align=right}},
    column sep=-\pgflinewidth,
    row sep=-\pgflinewidth
    ]
    {    |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  40  ]|\& |[fill=black!  6   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  27  ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  22  ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
         |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  18  ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  30  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  36  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  14  ]|\\
         |[fill=black!  3   ]|\& |[fill=black!  0   ]|\& |[fill=black!  12  ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  5   ]|\& |[fill=black!  0   ]|\& |[fill=black!  5   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  69  ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\\
         |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  7   ]|\& |[fill=black!  48  ]|\& |[fill=black!  1   ]|\& |[fill=black!  2   ]|\& |[fill=black!  16  ]|\& |[fill=black!  0   ]|\& |[fill=black!  6   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  14  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\\
         |[fill=black!  12  ]|\& |[fill=black!  0   ]|\& |[fill=black!  10  ]|\& |[fill=black!  22  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  9   ]|\& |[fill=black!  0   ]|\& |[fill=black!  17  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  20  ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\& |[fill=black!  5   ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\\
         |[fill=black!  3   ]|\& |[fill=black!  0   ]|\& |[fill=black!  22  ]|\& |[fill=black!  17  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  29  ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  20  ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\& |[fill=black!  4   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
         |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  5   ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  22  ]|\& |[fill=black!  0   ]|\& |[fill=black!  5   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  45  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  17  ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\\
         |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\& |[fill=black!  84  ]|\& |[fill=black!  3   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  10  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
         |[fill=black!  0   ]|\& |[fill=black!  9   ]|\& |[fill=black!  1   ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\& |[fill=black!  4   ]|\& |[fill=black!  0   ]|\& |[fill=black!  38  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  33  ]|\& |[fill=black!  0   ]|\& |[fill=black!  6   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\\
         |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  17  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  49  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  34  ]|\\
         |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  5   ]|\& |[fill=black!  0   ]|\& |[fill=black!  5   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  35  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  55  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
    };
    \end{tikzpicture}
    }
    \subcaptionbox{Cluster 5, $\pi_5 = 0.20$}{
    \begin{tikzpicture}[font=\ttfamily, ampersand replacement=\&]
    \matrix (A) [nodes in empty cells,
    matrix of nodes,
    nodes={draw, minimum size=3mm, inner sep=0pt, outer sep=0pt, anchor=center},
    %row 1/.style={nodes={draw=none, rotate=90, anchor=west, inner xsep=1mm}},
    column 1/.style={nodes={draw=none, minimum width=43mm, text width=40mm, align=right}},
    column sep=-\pgflinewidth,
    row sep=-\pgflinewidth
    ]
    {AC \& |[fill=black!    1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  12  ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  84  ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
    CH  \& |[fill=black!    0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  16  ]|\& |[fill=black!  3   ]|\& |[fill=black!  0   ]|\& |[fill=black!  40  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  41  ]|\\
    DP  \& |[fill=black!    2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  14  ]|\& |[fill=black!  4   ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\& |[fill=black!  10  ]|\& |[fill=black!  0   ]|\& |[fill=black!  10  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  56  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\\
    HP  \& |[fill=black!    0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  4   ]|\& |[fill=black!  69  ]|\& |[fill=black!  1   ]|\& |[fill=black!  1   ]|\& |[fill=black!  15  ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  5   ]|\\
    IA  \& |[fill=black!    4   ]|\& |[fill=black!  3   ]|\& |[fill=black!  0   ]|\& |[fill=black!  37  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  19  ]|\& |[fill=black!  0   ]|\& |[fill=black!  27  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  7   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
    LB  \& |[fill=black!    4   ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\& |[fill=black!  37  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  36  ]|\& |[fill=black!  1   ]|\& |[fill=black!  7   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  6   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  4   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\\
    LP  \& |[fill=black!    7   ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\& |[fill=black!  4   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  30  ]|\& |[fill=black!  0   ]|\& |[fill=black!  8   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  42  ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\\
    NL  \& |[fill=black!    0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\& |[fill=black!  5   ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\& |[fill=black!  7   ]|\& |[fill=black!  83  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
    SC  \& |[fill=black!    0   ]|\& |[fill=black!  12  ]|\& |[fill=black!  1   ]|\& |[fill=black!  1   ]|\& |[fill=black!  1   ]|\& |[fill=black!  2   ]|\& |[fill=black!  5   ]|\& |[fill=black!  0   ]|\& |[fill=black!  57  ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  15  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  6   ]|\\
    show\_discount  \& |[fill=black!    0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  14  ]|\& |[fill=black!  0   ]|\& |[fill=black!  86  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
    show\_funnel    \& |[fill=black!    0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  7   ]|\& |[fill=black!  0   ]|\& |[fill=black!  89  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  4   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
    };
    \end{tikzpicture}
    }
    \subcaptionbox{Cluster 6, $\pi_6 = 0.08$}{
    \begin{tikzpicture}[font=\ttfamily, ampersand replacement=\&]
    \matrix (A) [nodes in empty cells,
    matrix of nodes,
    nodes={draw, minimum size=3mm, inner sep=0pt, outer sep=0pt, anchor=center},
    %row 1/.style={nodes={draw=none, rotate=90, anchor=west, inner xsep=1mm}},
    %column 1/.style={nodes={draw=none, minimum width=43mm, text width=40mm, align=right}},
    column sep=-\pgflinewidth,
    row sep=-\pgflinewidth
    ]
    {    |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  50  ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  4   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  44  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
         |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  8   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  14  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  76  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\\
         |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  91  ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
         |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  5   ]|\& |[fill=black!  17  ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  6   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  67  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  2   ]|\\
         |[fill=black!  0   ]|\& |[fill=black!  3   ]|\& |[fill=black!  17  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  77  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
         |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  22  ]|\& |[fill=black!  21  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  13  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  40  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
         |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  3   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  86  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  6   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
         |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  100 ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
         |[fill=black!  0   ]|\& |[fill=black!  9   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  1   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  6   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  83  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
         |[fill=black!  16  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  16  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  67  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
         |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  26  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  74  ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\& |[fill=black!  0   ]|\\
     };
    \end{tikzpicture}
    }
    \label{TP_sessionS5}
    \caption{Transition probabilities of session data using MMM}
    \end{figure}
    \end{document}

UPDATE: after implementing the suggestion

enter image description here

2

Probably it's caused by the fact that you have

column 1/.style={nodes={draw=none, minimum width=43mm, text width=40mm, align=right}},

in the fifth subfigure, while in the first and third you have

column 1/.style={nodes={draw=none,minimum width=30mm, text width=28mm, align=right}},

Because the nodes in the first column in the fifth subfigure are wider, there is more whitespace to the left of it, and so it appears to be shifted right.

Set the minimum width/text width to the same value for all of them. If the content of the first column is always the same, you could also just remove those settings altogether.

3
  • You are right! Thank you. However, now the 6th is in a weird place. I added the outcome in my original question.
    – VivEUR
    Feb 16 '17 at 10:56
  • 2
    @VivEUR Try adding \centering right after \begin{figure}. Feb 16 '17 at 11:06
  • Basically, the boxes are being packed into a paragraph like words, and the last line of a paragraph (\flushright) is shorter. So \centering or \raggedright or any number of formatting tricks will fix it. Feb 16 '17 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.