如何从内部和外部对圆圈进行编号,例如我需要绿色圆圈从内部编号为1,2,3,从外部编号为user1,user2,user3。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\pagestyle{empty}
\def\layersep{3 cm}
\begin{tikzpicture}[shorten >=1pt,->,draw=black!50, node distance=\layersep]
\tikzstyle{every pin edge}=[<-,shorten <=1pt]
\tikzstyle{neuron}=[circle,fill=black!25,minimum size=17pt,inner sep=0pt]
\tikzstyle{input neuron}=[neuron, fill=green!50];
\tikzstyle{hidden neuron}=[neuron, fill=red!50];
\tikzstyle{annot} = [text width=4em, text centered]
% Draw the input layer nodes
% This is the same as writing \foreach \name / \y in {1/1,2/2,3/3,4/4}
\foreach \name / \y in {1,...,3}
\path[yshift=0.5cm]
node[input neuron] (I-\name) at (0,-\y cm) {};
% Draw the hidden layer nodes
\foreach \name / \y in {1,...,6}
\path[yshift=0.5cm]
node[hidden neuron] (H-\name) at (\layersep,-\y cm) {};
% Connect every node in the input layer with every node in the
% hidden layer.
\foreach \source in {1,...,3}
\foreach \dest in {1,...,6}
\path (I-\source) edge (H-\dest);
% Annotate the layers
\node[annot,above of=H-1, node distance=1cm] (hl) {SCs};
\node[annot,left of=hl] {Users};
\end{tikzpicture}
% End of code
\end{document}
答案 0 :(得分:1)
试试这个:
...
% Draw the input layer nodes
% This is the same as writing \foreach \name / \y in {1/1,2/2,3/3,4/4}
\foreach \name / \y in {1,...,3}
\path[yshift=0.5cm]
node[input neuron,label={160:user\y}] (I-\name) at (0,-\y cm) {\y};
...
在上面,160是绘制外部标签的角度。
答案 1 :(得分:0)
将MWE第26行中的{}
更改为{\y}
:
node[hidden neuron] (H-\name) at (\layersep,-\y cm) {\y};
并添加
\foreach \y in {1,...,3}
\node[yshift=0.5cm] at (-1,-\y cm) {user \y};
第21行和第23行之间的,你得到的输出与@xxa的答案一致: