我用了这先前的解决方案成功地在我的图表中垂直分割了一个节点。
但是使用此解决方案会导致图形表示混乱。
我怎样才能解决这个问题?
提前致谢!
例子:
\documentclass{minimal}
\usepackage{graphics}
\usepackage{tikz}
\usetikzlibrary{shapes,snakes}
\begin{document}
\begin{tikzpicture}
%%% Sum (Center)
\node[circle split,draw, rotate=90] (left) {\rotatebox{-90}{$\Sigma$} \nodepart{lower} \rotatebox{-90}{$\sigma$}};
%\node[circle split,draw] (left) {$\Sigma$};
%%% Output left to sum
\node[right=5em of left] (empty) {Ausgang};
\draw[->] (left) to (empty);
%%% Input 2
\node[circle, draw,left=5em of left] (2) {$x_2$};
\path[draw,->] (2) -- node[above] {$w_2$} (left);
%%% Input 1
\node[circle, draw,above of=2] (1) {$x_1$};
\draw[->] (1) to[bend right=-15] node[above] {$w_1$} (left);
%%% Input bias
\node[circle, draw,above=1em of 1] (bias) {$Bias$};
\draw[->] (bias) to[bend right=-25] (left);
%\draw[->] (bias) to[bend right=-25] node[above] {$w_0$} (left);
%%% Input 3
\node[circle, draw,below of=2] (3) {$x_3$};
\draw[->] (3) to[bend right=15] node[above] {$w_3$} (left);
%%% Dots
\node[below of=3] (dots) {$\vdots$};
%%% Input n
\node[circle, draw,below of=dots] (n) {$x_n$};
\draw[->] (n) to[bend right=25] node[above] {$w_n$} (left);
%%% Input label
\node[left=1em of 2,font=\scriptsize] {Eingänge};
\end{tikzpicture}
\end{document}
答案1
当你旋转一个节点时,锚点也会旋转,因此east
当你有 时,锚点最终会位于节点的顶部rotate=90
。当你right=of left
在 选项中执行 时empty
,positioning
库会使用east
的锚点left
作为参考,并且由于它现在位于节点的顶部,所以事物是倾斜的。
对于相对于 放置的两个节点,使用right=5em of left.south
和,以强制使用正确的参考点。left=5em of left.north
left
另外:不要使用该类minimal
。例如,它没有定义字体切换命令,例如\scriptsize
,您的示例(在添加缺失的positioning
库之后)会抛出错误font=\scriptsize
。(请参阅为什么要避免使用最小类?)
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning}
\begin{document}
\begin{tikzpicture}
%%% Sum (Center)
\node[circle split,draw, rotate=90] (left) {\rotatebox{-90}{$\Sigma$} \nodepart{lower} \rotatebox{-90}{$\sigma$}};
%\node[circle split,draw] (left) {$\Sigma$};
%%% Output left to sum
\node[right=5em of left.south] (empty) {Ausgang};
\draw[->] (left) to (empty);
%%% Input 2
\node[circle, draw,left=5em of left.north] (2) {$x_2$};
\path[draw,->] (2) -- node[above] {$w_2$} (left);
%%% Input 1
\node[circle, draw,above of=2] (1) {$x_1$};
\draw[->] (1) to[bend right=-15] node[above] {$w_1$} (left);
%%% Input bias
\node[circle, draw,above=1em of 1] (bias) {Bias};
\draw[->] (bias) to[bend right=-25] (left);
%\draw[->] (bias) to[bend right=-25] node[above] {$w_0$} (left);
%%% Input 3
\node[circle, draw,below of=2] (3) {$x_3$};
\draw[->] (3) to[bend right=15] node[above] {$w_3$} (left);
%%% Dots
\node[below of=3] (dots) {$\vdots$};
%%% Input n
\node[circle, draw,below of=dots] (n) {$x_n$};
\draw[->] (n) to[bend right=25] node[above] {$w_n$} (left);
%%% Input label
\node[left=1em of 2,font=\scriptsize] {Eingänge};
\end{tikzpicture}
\end{document}
答案2
我为你的图像编写代码的方式:用于定位节点的是tikz
库chains
,而用于边的权重的是quotes
:
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{chains, positioning, quotes, shapes.multipart}
\begin{document}
\begin{tikzpicture}[
node distance = 4mm and 20mm,
start chain = A going below,
circ/.style = {circle, draw, minimum size=2em, inner sep=1pt,
font=\small, on chain=A},
every edge quotes/.append style = {inner sep=2pt, pos=0.4}
]
\node[circ] {Bias}; % name: A-1
\node[circ] {$w_1$}; % name: A-2
\node[circ,label=left:Eingänge] {$w_2$};
\node[circ] {$w_3$};
\coordinate[on chain] (aux1);
\node[circ] (n) {$w_n$}; % name: A-6
%%%% sum
\node[circle split, draw, right=of A-3,
rotate=90,anchor=center] (sum) {\rotatebox{-90}{$\Sigma$} \nodepart{lower} \rotatebox{-90}{$\sigma$}};
%%% Output left to sum
\node[right=5em of sum.center] (out) {Ausgang};
\draw[->] (A-1) edge [bend left] (sum)
(A-2) edge [bend left, "$w_1$"] (sum)
(A-3) edge ["$w_2$"] (sum)
(A-4) edge [bend right,"$w_3$"] (sum)
(A-6) edge [bend right,"$w_n$"] (sum);
\draw[very thick, loosely dotted, shorten >=6pt, shorten <=6pt] (A-4) -- (A-6);
\draw[->] (sum) -- (out);
\end{tikzpicture}
\end{document}