![如何给循环箭头贴上标签?](https://linux22.com/image/401160/%E5%A6%82%E4%BD%95%E7%BB%99%E5%BE%AA%E7%8E%AF%E7%AE%AD%E5%A4%B4%E8%B4%B4%E4%B8%8A%E6%A0%87%E7%AD%BE%EF%BC%9F.png)
我想绘制 rnn 的循环层。因此,我使用以下代码,但无法在循环箭头上放置标签 (\nu)。图片显示了我想要的输出,只是缺少一个标签。
您知道如何实现这个目标吗?
\documentclass[tikz,border=2mm]{standalone}
\begin{document}
\begin{tikzpicture}
[ cnode/.style={draw=black,fill=#1,minimum width=3mm,circle},
]
% add fourth input (n)
\node[cnode=blue,label=180:$x$] (x) at (0,0) {};
\node[cnode=gray,label=110:$x^{(1)}$] (h) at (0,2) {};
\draw [->](x) -- node[right,pos=0.45] {$\omega$} (h);
\draw [->](h) to [out=30,in=330,looseness=15] {$\nu$} (h);
\end{tikzpicture}
\end{document}
答案1
只需添加node[right]
。
\documentclass[tikz,border=2mm]{standalone}
\begin{document}
\begin{tikzpicture}
[ cnode/.style={draw=black,fill=#1,minimum width=3mm,circle},
]
% add fourth input (n)
\node[cnode=blue,label=180:$x$] (x) at (0,0) {};
\node[cnode=gray,label=110:$x^{(1)}$] (h) at (0,2) {};
\draw [->](x) -- node[right,pos=0.45] {$\omega$} (h);
\draw [->](h) to [out=30,in=330,looseness=15] node[right]{$\nu$} (h);
\end{tikzpicture}
\end{document}
您也可以与 合作quotes
。
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{quotes}
\begin{document}
\begin{tikzpicture}
[ cnode/.style={draw=black,fill=#1,minimum width=3mm,circle},
]
% add fourth input (n)
\node[cnode=blue,label=180:$x$] (x) at (0,0) {};
\node[cnode=gray,label=110:$x^{(1)}$] (h) at (0,2) {};
\draw [->](x) -- node[right,pos=0.45] {$\omega$} (h);
\draw [->](h) to [out=30,in=330,looseness=15,"$\nu$"] (h);
\end{tikzpicture}
\end{document}