Can someone please tell me how to do the diagram below?

enter image description here


2 Answers 2


You can try with a matrix

\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{matrix, positioning, arrows.meta}

\begin{tikzpicture}[line/.style={-Stealth, shorten >=2pt, shorten <=2pt}]
\matrix[matrix of math nodes, nodes={minimum size=8mm, anchor=center}, nodes in empty cells](A){
& A & B & C & D \\
A & & & & \\
B & & & & \\
C & & & & \\
D & & & & \\};
\foreach \i/\j in {2-2/2-4, 2-5/2-4, 3-2/3-3, 3-5/3-3, 4-2/4-3, 4-5/4-3, 5-2/5-5} 
\draw[line] (A-\i.center)--(A-\j.center);
\foreach \i/\j in {5-2/2-2, 2-3/4-3, 5-3/4-3, 2-4/3-4, 5-4/3-4, 2-5/4-5, 5-5/4-5} 
\draw[line] (A-\i.center)--(A-\j.center);
\draw (A-1-1.north east)--(A-5-1.south east) (A-1-1.south west)--(A-1-5.south east);
\path (A-1-3)--(A-1-4) node[midway, above=3mm]{Colin};
\path (A-3-1)--(A-4-1) node[midway, rotate=90, left=3mm, anchor=south]{Rose};


enter image description here

  • Wow, this solution is very elegant! I never understood why one should use tikz-matrizes, now I do! :)
    – pbaer
    Mar 17, 2020 at 10:11

For one example it is probably easier to hard code everything but since every up arrow meets a corresponding down arrow, and every left arrow meets a right arrow, it seems natural to loop over the heights and lengths of the vertical and horizontal arrows. The main advantage of doing it this way is that this makes it possible to create a macro for drawing these diagrams. Once this is done you can produce the diagrams

enter image description here

using the lines:


You could make the names Colin and Rose be parameters to the \MovementDiagram macro too. Another possibility, which requires a fraction more work, would be to allow the grid size to be set automatically from the lengths of the vertical and horizontal lists. Here is the full code:


\begin{tikzpicture}[thick, move/.style={arrows={-Latex[width=4pt,length=8pt]}}]
    % loop over the vertical arrows using their heights
    \foreach  \y [count=\x] in {#1} {
       \draw[move] (\x,1.05)--+(0,\y-0.1);
       \ifnum \y<3
         \draw[move] (\x,3.95)-- +(0,\y-2.9);
       \node at (\x,4.6) {\AlphAlph\x};
    % now the horizontal arrows using their lengths
    \foreach  \x [count=\y, evaluate=\y as \Y using {int(5-\y)}] in {#2} {
       \draw[move] (1.05,\y)--+(\x-0.1,0);
       \ifnum \x<3
         \draw[move] (3.95,\y)-- +(\x-2.9,0);
       \node at (0.2,\y) {\AlphAlph\Y};
    % finally draw the "axes" and Rose and Colin
    \node at (-0.6,2.5){Rose};
    \node at (2.5,5.2){Colin};



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .