Hervorheben von Zonen in einem Waldbaum

Hervorheben von Zonen in einem Waldbaum

Ich möchte verschiedene Bereiche des Baums mit unterschiedlichen Farben hervorheben und sie durch eine bogenförmige Linie trennen. Gibt es eine Möglichkeit, das zu tun?

Das Ergebnis, das ich erzielen möchte, ist ungefähr dieses:

Bildbeschreibung hier eingeben

Der Code meines Baumes ist der folgende:

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

Vielen Dank im Voraus an alle, die eine Lösung haben!

Antwort1

Mit ein paar Tricks unter Verwendung der calcBibliothek und der fillbetweenvon bereitgestellten Bibliothek pgfplotskönnten Sie Folgendes erreichen (ich nehme an, dass dies nicht unbedingt der einfachste Weg ist):

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

Bildbeschreibung hier eingeben

Erläuterung:

  • Ich zeichne zunächst drei elliptische Bögen, die relativ zu den Knoten im Baum positioniert sind . CPDazu benenne ich die Knoten im Baum mit der vom Paket bereitgestellten Option.TPVPnameforest
  • Ich erstelle einen vierten Bogen relativ zu einem Knoten (Koordinate), der genau so weit von VP entfernt ist wie VP von TP, aber in die entgegengesetzte Richtung. Diese Berechnung kann mithilfe der calcBibliothek und der Syntax durchgeführt werden $(vp)!-1!(tp)$.
  • Ich benenne diese vier Bögen mit name pathund nutze dann die intersection segmentsOption der fillbetweenBibliothek, die mit PGFplots geliefert wird (und die im Detail imHandbuch derzeit in Abschnitt 5.7), um Füllungen dazwischen zu erzeugen.
  • Die drei Füllungen habe ich auf die Hintergrundebene gelegt, sodass sie die Knoten nicht verdecken.

Eine Variante mit Schattierungen:

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

Bildbeschreibung hier eingeben

verwandte Informationen