[Tex/LaTex] tikz – command node – text

tikz-pgf

my MWE is:

\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usetikzlibrary{calc}

\begin{document}
  \begin{tikzpicture}[domain=0:2*pi] 
    \draw[xstep=pi/4, ystep=0.5, dashed, color=gray] (-0.1,-1.6) grid (2*pi,1.6); 
    \draw[->] (-0.2,0) -- (7,0) node[right] {$t$}; 
    \draw[->] (0,-2) -- (0,2) node[above] {$i(t)$}; 
    \node[below left](0,0){$0$};
    \draw[color=blue, smooth]   plot (\x,{sin(\x r)})    node[below right] {$i(t)$}; 
    \node[below left] at (2,2) {$i(t) = I_0\sin\omega t$};
  \end{tikzpicture}
\end{document}

In the last command I try to put the text $i(t) = I_0\sin\omega t$ at coordinate (2,2), but the result does not match my expectations. Where is problem? How to insert text at a certain position without depending on previous commands?

I got this image:
enter image description here

I expected that the text $i(t) = I_0\sin\omega t$ will be more right.

Best Answer

If you want it to be more right, then you should specify below right and not below left:

\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usetikzlibrary{calc}

\begin{document}
  \begin{tikzpicture}[domain=0:2*pi] 
    \draw[xstep=pi/4, ystep=0.5, dashed, color=gray] (-0.1,-1.6) grid (2*pi,1.6); 
    \draw[->] (-0.2,0) -- (7,0) node[right] {$t$}; 
    \draw[->] (0,-2) -- (0,2) node[above] {$i(t)$}; 
    \node[below left](0,0){$0$};
    \draw[color=blue, smooth]   plot (\x,{sin(\x r)})    node[below right] {$i(t)$}; 
    \node[below right] at (2,2) {$i(t) = I_0\sin\omega t$};
  \end{tikzpicture}
\end{document}

You can find more information on positioning nodes in the pgfmanual, section 16.5.