2

I am trying to rotate one row of a matrix of nodes. Is it possible?

MWE (rotation does not work):

\documentclass{standalone}
\usepackage{tikz}

\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix [matrix of nodes,nodes={circle,draw},
row 1/.style={align=left,rotate=90}]
{
t & &  \\
y & & v \\
h & g & \\
};
\end{tikzpicture}
\end{document}
0
3

You have to use transform shape to rotate the contents of a node. Further, you may wish to add anchor=center.

\documentclass{standalone}
\usepackage{tikz}

\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix [matrix of nodes,nodes={circle,draw,text depth=0.5ex,text height=1.5ex},
row 1/.style={nodes={align=left,rotate=90,anchor=center,transform shape}}]
{
t & &  \\
y & & v \\
h & g & \\
};
\end{tikzpicture}
\end{document}

enter image description here

Further, it is better to use text width so that all nodes align. Finally as mentioned by percusse apply the rotate operation only on nodes by

row 1/.style={nodes={align=left,rotate=90,anchor=center,transform shape}}
1
  • 2
    Use row 1/.style={nodes={align=left,rotate=90}} syntax instead otherwise bad things will happen.
    – percusse
    Feb 2 '15 at 13:57

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.