Positioning and aligning nodes
We have already learned how to place nodes at coordinates and use anchors for that. Let’s explore more options.
Using anchors and relative positioning
First, perhaps you noticed that positioning based on anchors can feel counterintuitive: to place a node above an object (north of it), we use the south
anchor.
For example, here we draw a node above a circle:
\draw circle [fill, radius=2pt] node [anchor=south] {text};
The output of that command is shown in the following picture:
Figure 3.13 – A node above a circle
For more intuitive positioning, TikZ offers other statements. We can write the same line in this way:
\draw circle [fill, radius=2pt] node [above] {text};
That gives the same output as in Figure 3.13, and feels more natural.
In that spirit, these are the new relative positioning options:
above
: Similar toanchor=south
below
: Similar toanchor=north
left
: Similar...