How can the distance from a TikZ node to its label be changed?

Setting label distance I think.

\documentclass[tikz, border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[label distance=5mm]
    \draw[step=1cm] (0,0) grid (5,1);
    \node[label=above:\rotatebox{-45}{king} ] at (0.5,0.5) {0};
    \node[label={[label distance=1cm]above:\rotatebox{-45}{queen}}] at (1.5,0.5) {1};
    \node[label=above:\rotatebox{-45}{man}  ] at (2.5,0.5) {0};
    \node[label=above:\rotatebox{-45}{woman}] at (3.5,0.5) {0};
    \node[label=above:\rotatebox{-45}{child}] at (4.5,0.5) {0};
\end{tikzpicture}
\end{document}

enter image description here


You can place the labels with numbers(for example 90 instead of above) and add a distance. With adding label distance=<...> like this:

\node[label={[label distance=2mm]90:\rotatebox{-45}{king}}]

See: Tikz manual http://vesta.informatik.rwth-aachen.de/ftp/pub/mirror/ctan/graphics/pgf/base/doc/pgfmanual.pdf

-> 3.9 Adding Labels Next to Nodes (p.52) it says: number instead of things like below left -> 17.10.2 The Label option label (p.340) : The is additionally inserted between the main node and the label node.

enter image description here

MWE:

\documentclass[tikz, border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    \draw[step=1cm] (0,0) grid (5,1);
    \node[label={[label distance=2mm]90:\rotatebox{-45}{king}}] at (0.5,0.5) {0};
    \node[label={[label distance=2mm]90:\rotatebox{-45}{queen}}] at (1.5,0.5) {1};
    \node[label={[label distance=2mm]90:\rotatebox{-45}{man}}] at (2.5,0.5) {0};
    \node[label={[label distance=2mm]90:\rotatebox{-45}{woman}}] at (3.5,0.5) {0};
    \node[label={[label distance=2mm]90:\rotatebox{-45}{child}}] at (4.5,0.5) {0};
\end{tikzpicture}
\end{document}