Destacando zonas em uma árvore florestal

Destacando zonas em uma árvore florestal

Gostaria de destacar diferentes zonas da árvore com cores diferentes, separando-as com uma linha arqueada. Existe uma maneira de fazer isso?

O resultado que gostaria de alcançar é algo assim:

insira a descrição da imagem aqui

O código da minha árvore é o seguinte:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{soul}
\usepackage{tikz}
\usepackage{forest}
\usepackage{ulem}
\usetikzlibrary{positioning,tikzmark}

\begin{document}

\begin{forest}
for tree={calign=fixed edge angles},
[CP [,phantom]
[C' 
[C]
[TP [,phantom]
[T' 
[T]
[VP [,phantom]
[V' 
[V] [,phantom]]]]]]]
\end{forest}

\end{document}

Agradecemos antecipadamente a quem tiver uma solução!

Responder1

Com alguns truques usando a calcbiblioteca e a fillbetweenbiblioteca fornecida por pgfplots, você poderia fazer o seguinte (esta pode não ser a maneira mais simples de conseguir isso, presumo):

\documentclass[border=10pt]{standalone}
\usepackage{forest}

\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\usepgfplotslibrary{fillbetween}

\usetikzlibrary{calc, backgrounds}

\begin{document}

\begin{forest}
for tree={calign=fixed edge angles},
[CP,name=cp [,phantom]
[C' 
[C]
[TP,name=tp [,phantom]
[T' 
[T]
[VP,name=vp [,phantom]
[V' 
[V] [,phantom]]]]]]]
\draw[rotate=30, name path=cpbow] ([shift={(150:2 and 0)}]cp) 
    arc[start angle=150, end angle=30, x radius=2, y radius=1];
\draw[rotate=30, name path=tpbow] ([shift={(150:2 and 0)}]tp) 
    arc[start angle=150, end angle=30, x radius=2, y radius=1];
\draw[rotate=30, name path=vpbow] ([shift={(150:2 and 0)}]vp) 
    arc[start angle=150, end angle=30, x radius=2, y radius=1];
\path[rotate=30, name path=xpbow] ([shift={(150:2 and 0)}]$(vp)!-1!(tp)$) 
    arc[start angle=150, end angle=30, x radius=2, y radius=1];
\begin{scope}[on background layer]
\fill[red, opacity=0.25, intersection segments={
        of=cpbow and tpbow, sequence={A* -- B*[reverse]}
    }] -- cycle;
\fill[yellow, opacity=0.25, intersection segments={
        of=tpbow and vpbow, sequence={A* -- B*[reverse]}
    }] -- cycle;
\fill[green, opacity=0.25, intersection segments={
        of=vpbow and xpbow, sequence={A* -- B*[reverse]}
    }] -- cycle;
\end{scope}
\end{forest}

\end{document}

insira a descrição da imagem aqui

Explicação:

  • Primeiro desenho três arcos elípticos que estão relativamente posicionados aos nós CPe TPna VPárvore. Faço isso nomeando os nós da árvore usando a nameopção fornecida pelo forestpacote.
  • Eu crio um quarto arco relativo a um nó (coordenada) que está exatamente tão longe de VP quanto VP está longe de TP, mas na direção oposta. Este cálculo pode ser feito usando a calcbiblioteca e a sintaxe $(vp)!-1!(tp)$.
  • Eu nomeio esses quatro arcos usando name pathe depois utilizo a intersection segmentsopção fornecida pela fillbetweenbiblioteca que acompanha o PGFplots (e que é descrita em detalhes nomanual atualmente na seção 5.7) para criar recheios entre eles.
  • Coloquei os três recheios na camada de fundo, para que não cubram os nós.

Uma variação usando sombreamentos:

\documentclass[border=10pt]{standalone}
\usepackage{forest}

\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\usepgfplotslibrary{fillbetween}

\usetikzlibrary{calc, backgrounds}

\begin{document}

\begin{forest}
for tree={calign=fixed edge angles},
[CP,name=cp [,phantom]
[C' 
[C]
[TP,name=tp [,phantom]
[T' 
[T]
[VP,name=vp [,phantom]
[V' 
[V] [,phantom]]]]]]]
\draw[rotate=30, name path=cpbow] ([shift={(150:2 and 0)}]cp) 
    arc[start angle=150, end angle=30, x radius=2, y radius=1];
\draw[rotate=30, name path=tpbow] ([shift={(150:2 and 0)}]tp) 
    arc[start angle=150, end angle=30, x radius=2, y radius=1];
\draw[rotate=30, name path=vpbow] ([shift={(150:2 and 0)}]vp) 
    arc[start angle=150, end angle=30, x radius=2, y radius=1];
\path[rotate=30, name path=xpbow] ([shift={(150:2 and 0)}]$(vp)!-1!(tp)$) 
    arc[start angle=150, end angle=30, x radius=2, y radius=1];
\begin{scope}[on background layer]
\shade[left color=red!25, right color=red!0, shading angle=30, intersection segments={
        of=cpbow and tpbow, sequence={A* -- B*[reverse]}
    }] -- cycle;
\shade[left color=yellow!25, right color=yellow!0, shading angle=30, intersection segments={
        of=tpbow and vpbow, sequence={A* -- B*[reverse]}
    }] -- cycle;
\shade[left color=green!25, right color=green!0, shading angle=30, intersection segments={
        of=vpbow and xpbow, sequence={A* -- B*[reverse]}
    }] -- cycle;
\end{scope}
\end{forest}

\end{document}

insira a descrição da imagem aqui

informação relacionada