I'm trying to set the position of the b
node based on the x
position of one, and the y
position of another node.
I use the let
function, as I learned from another thread.
In my code this somehow results in a slightly incorrect position where the node is positioned slightly lower than expected, resulting in a minor but noticeable gap.
Here you can see that the b
node and its label is below the y
position of node w1
:
I know this is a very minor problem, but I would like to understand it. What causes the gap?
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{shapes,arrows,3d,calc,fit,shadows,snakes,automata,backgrounds,petri,positioning,chains,decorations.pathreplacing}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture} [start chain=2,node distance=13mm, label distance=3mm]
\tikzstyle{init} = [
draw,
circle,
inner sep=2pt,
font=\Huge,
join = by -latex
]
\tikzstyle{squa} = [
draw,
inner sep=2pt,
font=\Large,
join = by -latex
]
\node[on chain=2] (x2) at (0,0) {$x_2$};
\node[on chain=2,join=by o-] {$w_2$};
\node[on chain=2,init] (sigma) {$\displaystyle\Sigma$};
\node[on chain=2,label=above:{\parbox{2cm}{\centering Activation \\ function}}] (phi) {$\phi(...)$};
\node[on chain=2,label=above:Output, join=by -latex] (y) {$y$};
\begin{scope}[start chain=1]
\node[on chain=1,label=above:Inputs] at (0,1.5cm) (x1) {$x_1$};
\node[on chain=1,label=above:Weights, join=by o-] (w1) {$w_1$};
\end{scope}
\begin{scope}[start chain=4]
\node[on chain=4] at (0,-1.5cm) (xn) {$x_{n}$};
\node[on chain=4,join=by o-] (wn) {$w_{n}$};
\end{scope}
\path let \p1=(sigma), \p2=(w1) in node[label=above:Bias] (b) at (\x1, \y2) {$b$};
\draw[-latex] (w1) -- (sigma);
\draw[-latex] (wn) -- (sigma);
\draw[o-latex] (b) -- (sigma);
\path (x2) -- (xn) node [font=\large, midway, sloped] {$\dots$};
\draw[-latex] (sigma) -- (phi) node[above, midway] (net) {\textit{net}};
\end{tikzpicture}
\caption{Structure of an Artificial Neuron}
\end{figure}
\end{document}