Ayuda con los círculos Tikz

Ayuda con los círculos Tikz

Estoy usando TikZ para dibujar un árbol ramificado y enlazado y necesito ayuda.

Aquí está mi código:

\documentclass[
    12pt,           
    oneside,                
    a4paper,            
    english,        
    french,     
    spanish,            
    brazil              
    ]{abntex2}
\usepackage{graphicx}
\usepackage{float}
\usepackage{tikz}
\usetikzlibrary{calc, shapes}

\begin{document}

\begin{figure}[H]
\centering
\tikzset{thick,
         tree node/.style = {align=center, inner sep=0pt, font = \scriptsize},
every label/.append style = {font=\scriptsize},
                 S/.style = {draw, circle, minimum size = 20mm, inner sep=0pt,
                             top color=white, bottom color=blue!20},
               ENL/.style = {% edge node left
                             font=\footnotesize, left=1pt},
               ENR/.style = {% edge node right
                             font=\footnotesize, right=1pt},
                     grow = down,
         sibling distance = 2.8cm,
           level distance = 3cm
           }
\begin{tikzpicture}
\node [S, label= 2:Some text here] {$PL0$}
    child{node [S] {$PL1$}
            child{node [S] {$PL3$}
            edge from parent node[ENL] {$x2 \leq 2$}}
            child{node [S] {$PL4$}
                 child{node [S] {$PL5$}
                     child{node [S] {$PL7$}
                     edge from parent node[ENL] {$x2 \leq 3$}}
                     child{node [S, label = 2:More text here] {$PL8$}
                     edge from parent node[ENR] {$x2 \geq 4$}}
          edge from parent node[ENL] {$x1 \leq 3$}}
          child{node [S, label = 2:Another text here] {$PL6$}
          edge from parent node[ENR] {$x1 \geq 4$}}
            edge from parent node[ENR] {$x2 \geq 3$}}
    edge from parent node[ENL] {$x1 \leq 4$}}
    child{node [S, label = 2:Last text here] {$PL2$}
    edge from parent node[ENR] {$x1 \geq 5$}};
\end{tikzpicture}
        \caption{My Figure.}
\end{figure}

\end{document}

Como resultado, deberías obtener esta cifra:

ingrese la descripción de la imagen aquí

Bueno, necesito ayuda con dos cosas aquí:

  1. Incluso usando el \centeringcomando, la figura no está centrada. ¿Que me estoy perdiendo aqui?

  2. Necesito escribir más información dentro de esos círculos. Por ejemplo, en el primero (PL0), debería tener esta información adicional:

ingrese la descripción de la imagen aquí

Intenté muchas cosas, pero no pude hacer que esa información encajara en el círculo.

Respuesta1

  1. La figuraescentrado. Para verificar esto, agregué marcos alrededor del área de texto y el archivo tikzpicture.
  2. Si desea más elementos en los círculos, debe agregarlos al contenido del nodo. Si desea permitir textos de varias líneas, debe agregar text widthla clave de alineación (o) adecuada, como align=center.

\documentclass[
    12pt,           
    oneside,                
    a4paper,            
    english,        
    french,     
    spanish,            
    brazil              
    ]{abntex2}
\usepackage[showframe]{geometry}
\usepackage{float}
\usepackage{tikz}
\usetikzlibrary{calc, shapes}

\begin{document}

\begin{figure}[H]
\centering
\tikzset{thick,
         tree node/.style = {align=center, inner sep=0pt, font = \scriptsize},
every label/.append style = {font=\scriptsize},
                 S/.style = {draw, circle, minimum size = 20mm, inner sep=0pt,
                             top color=white, bottom color=blue!20,
                             align=center}, %<-
               ENL/.style = {% edge node left
                             font=\footnotesize, left=1pt},
               ENR/.style = {% edge node right
                             font=\footnotesize, right=1pt},
                     grow = down,
         sibling distance = 2.8cm,
           level distance = 3cm
           }
\begin{tikzpicture}
\node [S, label= 2:Some text here] {$PL0$}
    child{node [S] {$PL0$\\ $x_1 = 4,333$ e\\ $x_2 = 2$ \\ $f = 42$}
            child{node [S] {$PL3$}
            edge from parent node[ENL] {$x2 \leq 2$}}
            child{node [S] {$PL4$}
                 child{node [S] {$PL5$}
                     child{node [S] {$PL7$}
                     edge from parent node[ENL] {$x2 \leq 3$}}
                     child{node [S, label = 2:More text here] {$PL8$}
                     edge from parent node[ENR] {$x2 \geq 4$}}
          edge from parent node[ENL] {$x1 \leq 3$}}
          child{node [S, label = 2:Another text here] {$PL6$}
          edge from parent node[ENR] {$x1 \geq 4$}}
            edge from parent node[ENR] {$x2 \geq 3$}}
    edge from parent node[ENL] {$x1 \leq 4$}}
    child{node [S, label = 2:Last text here] {$PL2$}
    edge from parent node[ENR] {$x1 \geq 5$}};
\draw (current bounding box.south west) rectangle (current bounding box.north east);    
\end{tikzpicture}
        \caption{My Figure.}
\end{figure}

\end{document}

ingrese la descripción de la imagen aquí

También recomiendo mirar el forestpaquete.

información relacionada