# Text position of a TikZ \node

Here is my code:

\documentclass{scrartcl}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}

\begin{document}
\begin{tikzpicture}

\node (circle) [draw, circle, minimum size = 20mm] at (0, 0) {}
(0, 0) node[above] {$I$};
\draw (circle.center) [{Rays[]}-|] -- (circle.east) node[below, midway] {$r$};
\draw (circle.east)                -- (2, 0) node[below, midway] {$r$};
\draw (2, 0) [|-{Circle[]}]        -- (3, 0) node[below, midway] {$r$} node[above] {P};

\end{tikzpicture}
\end{document}


The line (0, 0) node[above] {$I$}; imposes to be integrated in to this line: \node (circle) [draw, circle, minimum size = 20mm] at (0, 0) {}. But I couldn't achieve it. How can I make this? Also any other optimization is welcome too.

The desired result (that I want to produce):

• What do you mean by 'integrated' exactly? Do you want the I to be on the border of the circular node? – cfr Jan 15 '17 at 23:05

I'm not sure I've understood correctly, but do you want something like this?

\documentclass[border=10pt,multi,tikz]{standalone}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\node (circle) [draw, circle, minimum size = 20mm, label=above:$I$] at (0, 0) {};
\draw (circle.center) [{Rays[]}-|] -- (circle.east) node[below, midway] {$r$};
\draw (circle.east)                -- (2, 0) node[below, midway] {$r$};
\draw (2, 0) [|-{Circle[]}]        -- (3, 0) node[below, midway] {$r$} node[above] {P};
\end{tikzpicture}
\end{document}


Remember that a node is not the same as a path, so you cannot label it in the same way.

In effect, your original code places two nodes at the origin: first the circular one; then the $I$. This works because \node is equivalent to \path node. So you have \path node ... node ...; Hence, the second node is placed above the path, which consists of the point (0,0).

# EDIT

Addressing the clarified question, just put the node above the line's starting point. For example,

\documentclass[border=10pt,multi,tikz]{standalone}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\node (circle) [draw, circle, minimum size = 20mm] at (0, 0) {};
\draw (circle.center) [{Rays[]}-|] node [above] {$I$} -- (circle.east) node[below, midway] {$r$};
\draw (circle.east)                -- (2, 0) node[below, midway] {$r$};
\draw (2, 0) [|-{Circle[]}]        -- (3, 0) node[below, midway] {$r$} node[above] {P};
\end{tikzpicture}
\end{document}


There are other ways to do this, but this seems as straightforward to me as any.

• Hello @cfr! Thank you for an answer. Sorry for the long absence. I added a picture with the desired result to my question. – Su-47 Jan 20 '17 at 20:22
• @Su-47 Please see edit above. – cfr Jan 21 '17 at 1:40
• Hello @cfr! Thank you for the answer! This is really easy solution, but one must have the experience to do it. – Su-47 Jan 21 '17 at 15:14