Draw a line not touching edges

In your setting, you'd only need to use \draw ([yshift=-0.1cm]n1.south) -- ([yshift=0.1cm]n2.north);. However, one can draw your picture in a single picture without remember picture.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}


\begin{tikzpicture}
\node[fill opacity=0.1,circle,label=left:2016,fill=black,inner
sep=3pt,label={[xshift=5mm]right:bar},label={[xshift=2mm,yshift=-5mm]right:foo},] (N1){};
\node[below=1cm of N1,fill opacity=0.1,circle,label=left:2016,fill=black,inner
sep=3pt,label={[xshift=5mm]right:bar},label={[xshift=2mm,yshift=-5mm]right:foo}] (N2) {};
\draw ([yshift=-0.1cm]N1.south) -- ([yshift=0.1cm]N2.north);
\end{tikzpicture}
\end{document}

enter image description here

ADDENDUM: Using Zarko's way to define a universal style, one could use outer sep to produce the gaps. I would rather not use shorten as this can have unwanted side-effects if you consider using curved paths.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[pfft/.style={circle,fill opacity=0.1,fill=black,inner
sep=3pt,outer sep=1mm}]
\node[pfft,label=left:2016,,label={[xshift=5mm]right:bar},label={[xshift=2mm,yshift=-5mm]right:foo},] (N1){};
\node[below=1cm of N1,pfft,label=left:2016,label={[xshift=5mm]right:bar},label={[xshift=2mm,yshift=-5mm]right:foo}] (N2) {};
\draw (N1) -- (N2);
\end{tikzpicture}
\end{document}

And a third option, without yshift and without outer sep but shorten option in line between nodes:

\documentclass[tikz, margin=3.141592mm]{standalone}
\usetikzlibrary{positioning}

\begin{document}
    \begin{tikzpicture}[
node distance = 12mm,
   dot/.style = {circle, fill=black, fill opacity=0.1,
                 inner sep=3pt, %No outer sep like in Zarko's answer
                 node contents={}}
                        ]
\node (n1) [dot, label=left:2016, label={[xshift=3mm]right:bar}, label=below right:foo];
\node (n2) [dot, label=left:2017, label={[xshift=3mm]right:bar}, label=below right:foo,
            below=of n1];
\draw[shorten >=2pt, shorten <=2pt] (n1) -- (n2); %No `yshift` like in Marmot's answer
    \end{tikzpicture}
\end{document}

enter image description here


as complement to nice @marmot answer:

\documentclass[tikz, margin=3.141592mm]{standalone}
\usetikzlibrary{positioning}

\begin{document}
    \begin{tikzpicture}[
node distance = 12mm,
   dot/.style = {circle, fill=black, fill opacity=0.1,
                 inner sep=3pt, outer sep=2pt,
                 node contents={}}
                        ]
\node (n1) [dot, label=left:2016, label={[xshift=3mm]right:bar}, label=below right:foo];
\node (n2) [dot, label=left:2017, label={[xshift=3mm]right:bar}, label=below right:foo,
            below=of n1];
\draw (n1) -- (n2);
    \end{tikzpicture}
\end{document}

enter image description here

Tags:

Xetex

Tikz Pgf