
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:
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 calc
biblioteca e a fillbetween
biblioteca 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}
Explicação:
- Primeiro desenho três arcos elípticos que estão relativamente posicionados aos nós
CP
eTP
naVP
árvore. Faço isso nomeando os nós da árvore usando aname
opção fornecida peloforest
pacote. - 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
calc
biblioteca e a sintaxe$(vp)!-1!(tp)$
. - Eu nomeio esses quatro arcos usando
name path
e depois utilizo aintersection segments
opção fornecida pelafillbetween
biblioteca 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}