Como definir a distância entre irmãos individuais em uma árvore tikz-qtree?

Como definir a distância entre irmãos individuais em uma árvore tikz-qtree?

Eu fiz esta árvore para meu projeto de pesquisa. Acabei de renomear todos os atributos para esta pergunta. Você pode ver na imagem abaixo que os irmãos no topo estão muito congestionados e a imagem geral parece muito ruim. Como posso criar distância entre irmãos individuais para um determinado nível? Existe alguma outra maneira de embelezar este diagrama, para torná-lo mais profissional?

Código:

\documentclass[12pt]{article}

\usepackage[a4paper]{geometry}% just to demonstrate the effects

\usepackage{graphicx}
\usepackage{qtree}

%\usetikzlibrary{arrows}
\usepackage{tikz-qtree}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

%\usepackage{tikz}
\usepackage{tikz-qtree}
\usetikzlibrary{arrows}


\begin{document}

\resizebox{1\linewidth}{!}{%
\begin{tikzpicture}[grow=right]
\tikzset{every tree node/.style={align=center}}
\tikzset{level distance=90pt}
\tikzset{level 1/.style={sibling distance=-50pt}}
\tikzset{edge from parent/.append style={thick,-stealth}}
%\tikzset{execute at begin node=\strut}
\Tree[.text1length1 
        [.textlength1\\text2 
            [.text1lenght2 ]
            [.asdsdsd 
                [.asdasdsd 
                    [.text1leng
                        [.text1lenght2 ]
                        [.asdasdsd [.text1leng [.text1lengAcid ] ] ]
                    ]
                    [.text1leng [.text1lengAcid ]]
                ] %asdasdsd
                [.asdEERER 
                    [.text1lenght2 ]
                    [.asdasdsd [.text1leng [.text1lengAcid ] ] ]
                ]
                [.text1lenght2 ]
            ] %asdsdsd
            [.aASDASD 
                [.text1leng [.text1lengAcid ]
                [.ASDERESSD 
                    [.text1lenght2 ]]
                    [.asdsdsd
                        [.text1lenght2 ]
                        [.asdEERER 
                            [.text1lenght2 ] 
                            [.asdasdsd [.text1leng [.text1lengAcid ] ] ]
                        ]
                        [.asdasdsd
                            [.text1leng ][.text1lenght2 ]
                            [.text1leng [.text1lengAcid ] ]
                        ]
                    ]
                    [.aASDASD
                        [.text1leng [.text1lengAcid ] ]
                        [.ASDERESSD 
                            [.text1lenght2 ] 
                            [.asdsdsd 
                                [.text1lenght2 ] 
                                [.asdEERER [.text1lenght2 ] ]
                            ]
                        ]
                    ]
                ] 
            ] 
        ] 
        [.HelloWorld111     
            [.HelloWorld333 ] 
            [.text1leng [.text1lengAcid ] ]
        ]
        [.backPress     
            [.text1lengAcid ] 
        ]
        [.Hello ]
        [.World11333    
            [.HelloWorld333 ] 
            [.Jango ]
            [.text1leng [.text1lengAcid ] ]
        ]
    ]
\end{tikzpicture}
}

\end{document}

Saída:

insira a descrição da imagem aqui

Responder1

Aqui está uma variação dea árvore que você produziu usandoforest. Observe que parte do problema aqui é que não tenho ideia de como hifenizar algo como text1lenght2. Portanto, presumi que eles não podem ser hifenizados. Se pudessem, você poderia criar um resultado melhor.

Para evitar permitir que a árvore se expanda além do razoável, defini um estilo stepwise={}{}que percorrerá o caminho entre pai e filho em etapas. O caminho padrão se move horizontalmente/verticalmente em vez de voar reto como a águia, porque isso reduz as chances de a borda colidir com um nó.

Observe que se você usar uma árvore que cresce no sul, nada disso será necessário, pois as colisões não ocorrerão.

A árvore resultante é relativamente compacta: cabe em paisagem A4 sem escala. Como você provavelmente sabe, diagramas de escala devem ser evitados sempre que possível.

Aqui está o resultado:

árvore gradual

Aqui está o código:

\documentclass[border=5pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{forest}
\begin{document}
\tikzset{>=latex}

\forestset{
  stepwise/.style n args=2{
    edge path={
      \noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) |- +(#1,#2) |- (.child anchor)\forestoption{edge label};
    }
  }
}

\begin{forest}
  for tree={
    edge=->,
    grow=east,
    align=left,
    child anchor=west,
    edge path={
      \noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) |- (.child anchor)\forestoption{edge label};
    },
    font=\sffamily
  }
  [text1length1
    [textlength1\\text2
        [text1lenght2
        ]
        [asdsdsd
            [asdasdsd, stepwise={30pt}{-20pt}
                [text1leng
                    [text1lenght2]
                    [asdasdsd [text1leng [text1lengAcid]]]
                ]
                [text1leng [text1lengAcid]]
            ] %asdasdsd
            [asdEERER
                [text1lenght2]
                [asdasdsd [text1leng [text1lengAcid]]]
            ]
            [text1lenght2]
        ] %asdsdsd
        [aASDASD
            [text1leng [text1lengAcid]
            [ASDERESSD
                [text1lenght2]]
                [asdsdsd
                    [text1lenght2]
                    [asdEERER
                        [text1lenght2]
                        [asdasdsd [text1leng [text1lengAcid]]]
                    ]
                    [asdasdsd
                        [text1leng ][text1lenght2]
                        [text1leng [text1lengAcid]]
                    ]
                ]
                [aASDASD
                    [text1leng [text1lengAcid]]
                    [ASDERESSD
                        [text1lenght2]
                        [asdsdsd
                            [text1lenght2]
                            [asdEERER [text1lenght2]]
                        ]
                    ]
                ]
            ]
        ]
    ]
    [HelloWorld111
        [HelloWorld333]
        [text1leng [text1lengAcid]]
    ]
    [backPress
        [text1lengAcid]
    ]
    [Hello]
    [World11333
        [HelloWorld333, stepwise={25pt}{-15pt}]
        [Jango]
        [text1leng [text1lengAcid]]
    ]
  ]
\end{forest}

\end{document}

EDITARProvavelmente melhor com texto sem texto, o que também torna a árvore mais compacta horizontalmente.

Não recomendado para todos os contextos, mas uma árvore sombreada dinamicamente também é uma possibilidade:

árvore colorida

\documentclass[border=5pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{forest}
\begin{document}
\tikzset{>=latex}

\forestset{
  stepwise/.style n args=2{
    edge path={
      \noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) |- +(#1,#2) |- (.child anchor)\forestoption{edge label};
    }
  },
  my shading/.style={
    for tree={
      text/.wrap pgfmath arg={black!##1!#1}{10*level()},
      edge/.wrap pgfmath arg={->, draw=black!##1!#1}{10*level()},
    },
  },
}

\begin{forest}
  for tree={
    edge=->,
    grow=east,
    align=left,
    child anchor=west,
    edge path={
      \noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) |- (.child anchor)\forestoption{edge label};
    },
    font=\sffamily
  }
  [text1length1
    [textlength1\\text2, my shading=blue
        [text1lenght2, my shading=green
        ]
        [asdsdsd, my shading=blue!50!green
            [asdasdsd, stepwise={30pt}{-20pt}
                [text1leng
                    [text1lenght2]
                    [asdasdsd [text1leng [text1lengAcid]]]
                ]
                [text1leng [text1lengAcid]]
            ] %asdasdsd
            [asdEERER
                [text1lenght2]
                [asdasdsd [text1leng [text1lengAcid]]]
            ]
            [text1lenght2]
        ] %asdsdsd
        [aASDASD
            [text1leng [text1lengAcid]
            [ASDERESSD
                [text1lenght2]]
                [asdsdsd
                    [text1lenght2]
                    [asdEERER
                        [text1lenght2]
                        [asdasdsd [text1leng [text1lengAcid]]]
                    ]
                    [asdasdsd
                        [text1leng ][text1lenght2]
                        [text1leng [text1lengAcid]]
                    ]
                ]
                [aASDASD
                    [text1leng [text1lengAcid]]
                    [ASDERESSD
                        [text1lenght2]
                        [asdsdsd
                            [text1lenght2]
                            [asdEERER [text1lenght2]]
                        ]
                    ]
                ]
            ]
        ]
    ]
    [HelloWorld111, my shading=purple
        [HelloWorld333]
        [text1leng [text1lengAcid]]
    ]
    [backPress, my shading=red
        [text1lengAcid]
    ]
    [Hello, my shading=magenta]
    [World11333, my shading=orange
        [HelloWorld333, stepwise={25pt}{-15pt}]
        [Jango]
        [text1leng [text1lengAcid]]
    ]
  ]
\end{forest}

\end{document}

Responder2

Para melhorar a imagem, finalmente descobri como instalar a floresta. Abri o gerenciador de pacotes do MikTex em StatMenu->Programas->MikTex->PackageManger. Eu instalei floresta. Do diretório de instalação, copiei Forest.sty e colei no diretório de trabalho atual. Usando floresta, é assim que o diagrama acima se parece.

Código:

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{forest}

\begin{document}
\tikzset{>=latex}


\resizebox{0.8\textwidth}{!}{%
\begin{forest} for tree={align=center,edge=->,grow=east}
 [text1length1 
        [textlength1\\text2 
            [text1lenght2 ]
            [asdsdsd 
                [asdasdsd 
                    [text1leng
                        [text1lenght2 ]
                        [asdasdsd [text1leng [text1lengAcid ] ] ]
                    ]
                    [text1leng [text1lengAcid ]]
                ] %asdasdsd
                [asdEERER 
                    [text1lenght2 ]
                    [asdasdsd [text1leng [text1lengAcid ] ] ]
                ]
                [text1lenght2 ]
            ] %asdsdsd
            [aASDASD 
                [text1leng [text1lengAcid ]
                [ASDERESSD 
                    [text1lenght2 ]]
                    [asdsdsd
                        [text1lenght2 ]
                        [asdEERER 
                            [text1lenght2 ] 
                            [asdasdsd [text1leng [text1lengAcid ] ] ]
                        ]
                        [asdasdsd
                            [text1leng ][text1lenght2 ]
                            [text1leng [text1lengAcid ] ]
                        ]
                    ]
                    [aASDASD
                        [text1leng [text1lengAcid ] ]
                        [ASDERESSD 
                            [text1lenght2 ] 
                            [asdsdsd 
                                [text1lenght2 ] 
                                [asdEERER [text1lenght2 ] ]
                            ]
                        ]
                    ]
                ] 
            ] 
        ] 
        [HelloWorld111     
            [HelloWorld333 ] 
            [text1leng [text1lengAcid ] ]
        ]
        [backPress     
            [text1lengAcid ] 
        ]
        [Hello ]
        [World11333    
            [HelloWorld333 ] 
            [Jango ]
            [text1leng [text1lengAcid ] ]
        ]
    ]
\end{forest}
}
\end{document}

Foto:

insira a descrição da imagem aqui

informação relacionada