使用 tikz latex 在分类法或树中的节点上绘制一个圆圈

使用 tikz latex 在分类法或树中的节点上绘制一个圆圈

我是 tikz 新手,我想在树节点上添加一个圆圈,但我没有找到如何在节点上画圆圈的解决方案。如果有人有建议或可行的示例,那将是一个很大的帮助。谢谢 在此处输入图片描述

答案1

作为起点。通过使用forest绘制树:

\documentclass[border=3mm,
               preview]{standalone}
\usepackage[edges]{forest}
\usetikzlibrary{positioning,
                shapes.callouts}

\begin{document}
{
\tikzset{
         node distance = 3mm,
    every label/.style = {circle, fill=blue, minimum size=2em, 
                          inner sep=0pt, anchor=center,
                          font=\small\sffamily, text=white},
             CO/.style = {ellipse callout, inner sep=1pt,
                          callout absolute pointer={#1},
                          callout pointer width=1.2 mm, callout pointer shorten=-1mm,
                          fill=black, font=\small\sffamily, text=white},
           Root/.style = {double, rounded corners, fill=cyan!30,
                          font=\small\sffamily\bfseries},
        }
    \begin{forest}
for tree={              
% style of tree nodes
  font=\sffamily\small,
  draw, semithick,
        align = center,
    inner sep = 2mm,
% style of tree (edges, distances, direction)
         edge = {draw, semithick, -stealth},
parent anchor = south,
 child anchor = north,
         grow = south,
forked edge,            
        l sep = 12mm,   % level distance
     fork sep = 6mm,    % distance from parent to branching point
        s sep = 4mm
            }
[Support for\\ visually impaired, 
 Root, name=root
  [AAA\\ aaaa,label=south east:5]
  [BB\\ bbbbb bbb\\ bb bbb b bbb,label=south east:114]
]
\node[CO=(root.north east),above right=of root] {159};
    \end{forest}
}
\end{document}

在此处输入图片描述

相关内容