I want to highlight a certain path on a probability tree that I draw using tikz and forest (thanks to this source):
\documentclass[11pt]{article}
\usepackage{tikz}
\usepackage{forest,nicefrac}
\begin{document}
% Set the overall layout of the tree
\tikzstyle{level 1}=[level distance=3.5cm, sibling distance=3.5cm]
\tikzstyle{level 2}=[level distance=3.5cm, sibling distance=2cm]
% Define styles for bags and leafs
\tikzstyle{bag} = [text width=4em, text centered]
\tikzstyle{end} = [circle, minimum width=3pt,fill, inner sep=0pt]
% The sloped option gives rotated edge labels. Personally
% I find sloped labels a bit difficult to read. Remove the sloped options
% to get horizontal labels.
\begin{tikzpicture}[grow=right, sloped]
\node[bag] {}
child {
node[bag] {II $(2R,1B)$}
child {
node[end, label=right:
{$P(B\cap II)=\frac{1}{2}\cdot\frac{1}{3}$}] {}
edge from parent
node[above] {$B$}
node[below] {$\frac{1}{3}$}
}
child {
node[end, label=right:
{$P(R\cap II)=\frac{1}{2}\cdot\frac{2}{3}$}] {}
edge from parent
node[above] {$R$}
node[below] {$\frac{2}{3}$}
}
edge from parent
node[above] {$II$}
node[below] {$\frac{1}{2}$}
}
child {
node[bag] {I $(2R,4B)$}
child {
node[end, label=right:
{$P(B\cap I)=\frac{1}{2}\cdot\frac{4}{6}$}] {}
edge from parent
node[above] {$B$}
node[below] {$\frac{4}{6}$}
}
child {
node[end, label=right:
{$P(R\cap I)=\frac{1}{2}\cdot\frac{2}{6}$}] {}
edge from parent
node[above] {$R$}
node[below] {$\frac{2}{6}$}
}
edge from parent
node[above] {$I$}
node[below] {$\frac{1}{2}$}
};
\end{tikzpicture}
\end{document}
How can I highlight the path I,R? It can be highlight just by making the edges ticker or a different color or change the background color, whatever you think it is better practice.
Best Answer
like this?
for this you need only add option
[draw=red,ultra thick]
tochild
: