Destacar zonas en un árbol forestal.

Destacar zonas en un árbol forestal.

Me gustaría resaltar diferentes zonas del árbol con diferentes colores, separándolas con una línea arqueada. ¿Hay una manera de hacer eso?

El resultado que me gustaría lograr es algo parecido a este:

ingrese la descripción de la imagen aquí

El código de mi árbol es el siguiente:

\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}

¡Gracias de antemano a cualquiera que tenga una solución!

Respuesta1

Con algunos trucos al usar la calcbiblioteca y la fillbetweenbiblioteca proporcionada por pgfplots, puede hacer lo siguiente (supongo que esta podría no ser la forma más sencilla de lograrlo):

\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}

ingrese la descripción de la imagen aquí

Explicación:

  • Primero dibujo tres arcos elípticos que están relativamente posicionados con respecto a los CPnodos TPy VPen el árbol. Hago esto nombrando los nodos en el árbol usando la nameopción proporcionada por el forestpaquete.
  • Creo un cuarto arco relativo a un nodo (coordenada) que está exactamente tan lejos de VP como VP está de TP, pero en la dirección opuesta. Este cálculo se puede lograr utilizando la calcbiblioteca y la sintaxis $(vp)!-1!(tp)$.
  • Nombro estos cuatro arcos usando name pathy luego uso la intersection segmentsopción proporcionada por la fillbetweenbiblioteca que viene con PGFplots (y que se describe en detalle en elmanual actualmente en la sección 5.7) para crear rellenos entre ellos.
  • Puse los tres rellenos en la capa de fondo, para que no cubran los nodos.

Una variación que usa sombreados:

\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}

ingrese la descripción de la imagen aquí

información relacionada