我想知道如何添加一个从圆圈区域出来的箭头,如 Tikz 所示,并在箭头末端添加一些文字。以下是我目前所得到的
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}[halo/.style={line join=round,
double,line cap=round,double distance=#1,shorten >=-#1/2,shorten <=-#1/2},
halo/.default=7mm]
\node[circle,draw,fill=gray](s){s}
child{node[circle,draw,fill=white]{}
child{node[circle,draw,fill=gray]{}}
}
child{node[circle,draw,fill=white]{}
child{node[circle,draw,fill=gray]{}}
}
child{node[circle,draw,fill=white](R1){}
child{node[circle,draw,fill=gray](R2){}}
};
\begin{scope}[on background layer]
\draw[halo] (s) -- (R1.center) -- (R2);
\end{scope}
\path (R2.south) ++ (0,-3.5mm); % shorten does not get taken into account by the bounding box
\end{tikzpicture}
\end{document}
答案1
像这样?
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{backgrounds,calc}
\begin{document}
\begin{tikzpicture}[halo/.style={line join=round,
double,line cap=round,double distance=#1,shorten >=-#1/2,shorten <=-#1/2},
halo/.default=7mm]
\node[circle,draw,fill=gray](s){s}
child{node[circle,draw,fill=white]{}
child{node[circle,draw,fill=gray]{}}
}
child{node[circle,draw,fill=white]{}
child{node[circle,draw,fill=gray]{}}
}
child{node[circle,draw,fill=white](R1){}
child{node[circle,draw,fill=gray](R2){}}
};
\begin{scope}[on background layer]
\draw[halo] (s) -- (R1.center) coordinate[pos=0.8] (tip) -- (R2);
\end{scope}
\path (R2.south) ++ (0,-3.5mm); % shorten does not get taken into account by the bounding box
\draw[stealth-] ($ (tip)!3.5mm!-90:(s) $) to[bend right=20]
($ (tip)!1.2cm!-90:(s) $) node[above]{text};
\end{tikzpicture}
\end{document}