[Tex/LaTex] Positioning tikz nodes to the top

beamerpositioningtikz-pgf

I have four circles in a beamer frame,

\begin{tikzpicture}[% common options for the circles:
ball/.style = {circle, draw, align=center, anchor=north, inner sep=0}]

\node<1>[ball,text width=1.5cm,fill=blue!20,draw=blue!20] (Post) at (6,2) {Post};
\node<2,3,4>[ball,text width=1.5cm,fill=purple!20,draw=purple!20] (A) at (6,2) {A};


\node<2>[ball,text width=1.5cm,fill=blue!20,draw=blue!20] (B) at (9,2) {B};
\node<1,3,4>[ball,text width=1.5cm,fill=purple!20,draw=purple!20] (B) at (9,2) {B};


\node<3>[ball,text width=1.5cm,fill=blue!20,draw=blue!20] (C) at (12,2) {C};
\node<1,2,4>[ball,text width=1.5cm,fill=purple!20,draw=purple!20] (C) at (12,2) {C};

\node<4>[ball,text width=1.5cm,fill=blue!20,draw=blue!20] (D) at (15,2) {D};
\node<1,2,3>[ball,text width=1.5cm,fill=purple!20,draw=purple!20] (D) at (15,2) {D};


\end{tikzpicture}

The problem is, when I change the y-coordinate of a node, it shifts up relative to the others. But as soon as I change it to the same value for all of them– they all come back to the center.

How can I make them all shift to the top of the slide/frame?

Best Answer

By default, beamer centers the frame content vertically.

By changing one y coordinate value, the picture size changes, and so does the vertical position then, because of the centering. By changing all y values in the same way, the picture size remains the same, so all is centered again.

You could leave at least one invisible node or coordinate unchanged, to see an effect of changing y values.

For example, add

\node at (9,0) {};

and then change the other nodes - all will move then.

For complete top alignment, simply use the [t] option to the frame:

\begin{frame}[t]