TikZ: Advantage of position values attached with a unit?

These two expressions are in principle very different and give "accidentally" the same result. IMHO the clearest discussion of this site can be found in this nice answer by LoopSpace, out of which I recycle some relevant parts here. TikZ interprets (x,y) rather differently depending on whether or not x and y carry units.

  1. If they are dimensionless, then the coordinate (x,y) means x times unit vector in x direction plus y times unit vector in y direction.
  2. If they carry units, then it just means x to the right and y up.

By default, the unit vector in x direction is (1cm,0) and the unit vector in y direction is (0,1cm), such that for two dimensionless numbers x and y in the default settings (x,y) and (xcm,ycm) yield the same result, which is what your MWEs illustrate. However, if we change the basis vectors, this is no longer true, as the following example shows (using a rectangle may not be the best example to illustrate these issues, but at least it is simple).

\documentclass[border=5mm]{standalone}
\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}[font=\sffamily] 
        \begin{scope}[local bounding box=standard]
           \begin{scope}[local bounding box=without units 1]
            \draw (0, 0) rectangle (4, 4);
           \end{scope}
           \node[above] at (without units 1.north){without units};
           \begin{scope}[xshift=5cm,local bounding box=with units 1]
            \draw (0cm, 0cm) rectangle (4cm, 4cm);
           \end{scope}
           \node[above] at (with units 1.north){with units};
        \end{scope}   
        \node[rotate=90,above=2em] at (standard.west){standard unit vectors};
        \begin{scope}[local bounding box=nonstandard,
        yshift=-5cm,x={(0.75,0.25)},y={(0,0.8)}]   
           \begin{scope}[local bounding box=without units 2]
            \draw (0, 0) rectangle (4, 4);
           \end{scope}
           \node[above] at (without units 2.north){without units};
           \begin{scope}[xshift=5cm,local bounding box=with units 2]
            \draw (0cm, 0cm) rectangle (4cm, 4cm);
           \end{scope}
           \node[above] at (with units 2.north){with units};
        \end{scope}   
        \node[rotate=90,above=2em] at (nonstandard.west){nonstandard unit vectors};
    \end{tikzpicture}
\end{document}

enter image description here

Internally pgf uses pt as units, which is why the pgf key xshift=2 yields a shift by 2pt (as remarked by Zarko). However, this does not mean that the radii of circles get interpreted as pt, rather, as explained in this nice answer by LoopSpace the command \draw[ultra thick] (0,0) circle[x radius=2,y radius=2]; yields, in the default coordinate system, a circle of radius 2cm.

So a possible answer to the question

When should I type positioning values attached with a unit (e.g. \draw (0cm, 0cm)...) and when should I type them without a unit (e.g. simply \draw (0, 0)...)?

is

It depends on what you need and/or are doing. In many situations you install nonstandard coordinate systems for a reason, which is why you may not want to add cm when dealing with them.

Side-remark: the tikz-3dplot package adds cm to all coordinates, which can lead to confusion in some cases.


In complement to marmot's nice answer, the following picture may be helpful:

\documentclass[border=5mm]{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[x={(2cm,2cm)}, y={(0cm,2cm)},
                    every node/.style={inner sep=2pt}]
  \draw[blue, ->] (0,0) -- (1,0) node[below right] {$\vec{x}$};
  \draw[blue, ->] (0,0) -- (0,1) node[above]       {$\vec{y}$};

  \begin{scope}[shift={(1,0)}]  % very different from shift={(1cm,0)}
  \draw[red, ->] (0cm,0cm) -- (1cm,0cm) node[right] {$\vec{u}$};
  \draw[red, ->] (0cm,0cm) -- (0cm,1cm) node[above] {$\vec{v}$};
  \end{scope}
\end{tikzpicture}

\end{document}

enter image description here