Skip to content

Instantly share code, notes, and snippets.

@abikoushi
Created December 22, 2025 04:51
Show Gist options
  • Select an option

  • Save abikoushi/f7d3c0d24cb5a930d7cd5a32b322ffea to your computer and use it in GitHub Desktop.

Select an option

Save abikoushi/f7d3c0d24cb5a930d7cd5a32b322ffea to your computer and use it in GitHub Desktop.
A TikZ picture of HairEyeColor data
%ref:
%https://tex.stackexchange.com/questions/516073/how-to-draw-3d-matrix-using-tikz
%https://tikz.net/tikz-table/
%
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{matrix,positioning}
\begin{document}
\tikzset{
table/.style={
matrix of nodes,
row sep=-\pgflinewidth,
column sep=-\pgflinewidth,
nodes={
rectangle,
draw=black,
fill=white,
align=center
},
minimum height=1.5em,
text depth=0.5ex,
text height=2ex,
nodes in empty cells,
%%
% every row/.style={
% nodes={fill=white}
%},
column 1/.style={
nodes={text width=4em, font=\bfseries}
},
row 1/.style={
nodes={
fill=gray,
text=white,
font=\bfseries
}
}
}
}
\begin{tikzpicture}
\matrix (male) [table, text width=6em]
{
& Brown & Blue & Hazel & Green\\
Black & 32 & 11 & 10 & 3\\
Brown & 53 & 50 & 25 & 15\\
Red & 10 & 10 & 7 & 7\\
Blond & 3 & 30 & 5 & 8\\
};
\matrix (female)[xshift=-3.5em, yshift=-3em] [table, text width=6em]
{
& Brown & Blue & Hazel & Green\\
Black & 36 & 9 & 5 & 2\\
Brown & 66 & 34 & 29 & 14\\
Red & 16 & 7 & 7 & 7\\
Blond & 4 & 64 & 5 & 8\\
};
\draw[thick,-stealth] ([xshift=1ex]female.south east) -- ([xshift=1ex]male.south east) node[midway,below,rotate=45] {sex};
\draw[thick,-stealth] ([yshift=-1ex]female.south west) -- ([yshift=-1ex]female.south east) node[midway,below] {hair};
\draw[thick,-stealth] ([xshift=-1ex]female.north west) -- ([xshift=-1ex]female.south west) node[midway,above,rotate=90] {eye};
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment