1

如何从内部和外部对圆圈进行编号,例如,我需要将绿色圆圈从内部编号为 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}
4

2 回答 2

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 是绘制外部标签的角度。

于 2014-09-23T13:51:44.673 回答
0

更改{}{\y}MWE 的第 26 行:

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 的答案一致:

截屏

于 2015-07-04T11:24:14.343 回答