
\documentclass[tikz,border=10pt]{standalone}
\usepackage{pgfplots}
\usepackage{forest}
\usetikzlibrary{shadows}
\begin{document}
\begin{forest}
shade me/.style={%
bottom color=#1!25,
top color=#1!5,
draw=#1,
drop shadow,
font=\Huge,
},
my label/.style n args=2{%
edge label={node [midway, black, font=\sffamily\large, #1] {#2}}
},
where n children=0{%
shade me=green!95!gray,
}{%
if level=0{%
shade me=green!95!gray,
}{%
shade me=green!95!gray,
}
},
for tree={%
delay={content/.wrap value={\strut #1}},
edge={red,->},
l sep+=45pt,
s sep+=60pt
}
[100000 individuals
[100 affected, my label={above, xshift=1cm}{}
[{95\% true positives}, my label={below, xshift=-1.7cm}{}
[,phantom] [{95 + 999 test positive, Total = 1094}, my label={above, sloped}{}, name=aux1]]]
[99900 unaffected, my label={above, sloped}{}
[{1\% false positives}, my label={below, xshift=1.5cm}{}, name=aux
% [{95 + 999 test positive Total = 1094}, my label={above, sloped}{}]
]] ]
]
]
\draw[red, ->] (aux)--(aux1);
\end{forest}
\end{document}
Respuesta1
Tenga en cuenta que tuve que modificar su MWE de varias maneras para que estuviera listo para las preguntas antes de comenzar a trabajar en una solución.
Cuando una pregunta es inherentemente sobre una clase particular, un MWE adecuado debe utilizar esa clase. El primer cambio obviamente necesario en este caso esusar
beamer
. De lo contrario, no tiene sentido intentar implementar un descubrimiento incremental. (Quizás podrías jugar con labeamer
opción destandalone
, pero tu MWE no la usó).La segunda modificación obviamente necesaria es que antes de que puedas siquierapensarEn cuanto a las especificaciones de superposición sofisticadas, es necesario revisar la especificación del árbol, ya que es bastante inadecuada para una diapositiva Beamer tal como está. Es sencilloenorme.
Gran parte del código del árbol no se utiliza y puede eliminarse simplemente del ejemplo. Las etiquetas sin borde son tan buenas para este propósito, quizás mejores, que las vacías.
Hecho esto, aquí hay una solución basada en el método que uso, que está muy en deuda con los diversos autores, especialmente Qrrbrbirlbel, anotados en el código.
\begin{filecontents}{mytree.tex}
\documentclass[tikz,border=10pt,multi]{standalone}
\usepackage{forest}
\usetikzlibrary{shadows}
\begin{document}
\begin{forest}
shade me/.style={%
bottom color=#1!25,
top color=#1!5,
draw=#1,
},
where n children=0{%
shade me=green!95!gray,
}{%
if level=0{%
shade me=green!95!gray,
}{%
shade me=green!95!gray,
}
},
for tree={%
delay={content/.wrap value={\strut #1}},
edge={red,->},
l sep+=20pt,
s sep+=20pt,
from slide/.wrap pgfmath arg={#1}{int(level()+1)},
},
delay={%
for tree={%
visible on=<\forestoption{from slide}->,
alt=<\forestoption{from slide}->{drop shadow}{},
}
}
[100000 individuals
[100 affected
[{95\% true positives}
[,phantom
]
[{95 + 999 test positive, Total = 1094}, name=aux1
]
]
]
[99900 unaffected
[{1\% false positives}, tikz+={\scoped[visible on=<4>]{\draw [red, ->] () -- (aux1);}}
]
]
]
\end{forest}
\end{document}
\end{filecontents}
\documentclass{beamer}
\usepackage{forest,standalone}
\usetikzlibrary{shadows}
\tikzset{% set up for transitions using tikz with beamer overlays - developed by Daniel (http://tex.stackexchange.com/a/55849/) and, in ear lier form, by Matthew Leingang (http://tex.stackexchange.com/a/6155/) and modified for this use, I think by Qrrbrbirlbel (http://tex.stacke xchange.com/a/112471/)
invisible/.style={opacity=0,text opacity=0},
visible on/.style={alt=#1{}{invisible}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
},
}
\forestset{%
visible on/.style={% developed by Qrrbrbirlbel (http://tex.stackexchange.com/a/112471/)
for tree={%
/tikz/visible on={#1},
edge={/tikz/visible on={#1}}}},
% based on Qrrbrbirlbel's answer at http://tex.stackexchange.com/a/112895/
declare toks={from slide}{1},
}
\begin{document}
\begin{frame}
\centering
\input{mytree}
\end{frame}
\end{document}