\documentclass[tikz]{standalone}

\usepackage{tensorstyle}

\begin{document}

% 1: color
% 2: pos
\newcommand\drawParticle[2]{
    \draw[fill=#1] #2 circle (0.15);
}
% 1: pos
% 2: n particles
\newcommand\drawSite[2]{
    \pgfmathsetmacro\dx{0.06}
    \pgfmathparse{#2 > 5}
    \ifnum\pgfmathresult=1 \relax
        \drawParticle{bg4}{($#1+(+\dx,-\dx)$)}
    \fi
    \pgfmathparse{#2 > 4}
    \ifnum\pgfmathresult=1 \relax
        \drawParticle{bg3}{($#1+(+\dx,-\dx)$)}
    \fi
    \pgfmathparse{#2 > 3}
    \ifnum\pgfmathresult=1 \relax
        \drawParticle{bg2}{($#1+(-\dx,+\dx)$)}
    \fi
    \pgfmathparse{#2 > 2}
    \ifnum\pgfmathresult=1 \relax
        \drawParticle{bg3}{($#1+(-\dx,-\dx)$)}
    \fi
    \pgfmathparse{#2 > 1}
    \ifnum\pgfmathresult=1 \relax
        \drawParticle{bg1}{($#1+(+\dx,+\dx)$)}
    \fi
    \pgfmathparse{#2 > 0}
    \ifnum\pgfmathresult=1 \relax
        \drawParticle{bg2}{($#1+(+0.00,+0.00)$)}
    \fi
}
    

\begin{tikzpicture}[x=\unitCm cm,y=\unitCm cm, scale=\scale, transform shape]
    % \begin{scope}[shift={(0,0)}]
    %     \pgfmathsetmacro{\xlen}{0.3}
    %     \draw[->] (0,0) -- (\xlen,\xlen) node[anchor=south west] {$x$};
    %     \draw[->] (0,0) -- (0,2*\xlen) node[anchor=south] {$z$};
    %     \draw[->] (0,0) -- (2*\xlen,0) node[anchor=west] {$y$};
    % \end{scope}

    \begin{scope}[shift={(1.5,0.3)}]
        \pgfmathsetmacro\N{8} % N spins
        \pgfmathsetmacro\iMax{\N-1} % B idx
        \pgfmathsetmacro\siteDistance{1}
        \pgfmathsetmacro\labelY{1}
        \foreach \i in {0,...,\iMax} {
            \node (S\i) at (\siteDistance*\i,0) {};
            \node at ($(S\i)-(0,\labelY)$) {\i};
        }
        \node at ($(S0)-(,\labelY)$) {Site:};
        % spins
        \draw[thick] (S0) -- (S\iMax);
        \drawSite{(S0)}{5}
        \drawSite{(S1)}{2}
        \drawSite{(S2)}{3}
        \drawSite{(S3)}{4}
        \drawSite{(S4)}{0}
        \drawSite{(S5)}{5}
        \drawSite{(S6)}{1}
        \drawSite{(S7)}{3}
        % \drawSite{(S8)}{1}
    \end{scope}

    
\end{tikzpicture}

\end{document}


