If you dissect +.gg
we have:
> ggplot2:::`+.gg`
function (e1, e2)
{
e2name <- deparse(substitute(e2))
if (is.theme(e1))
add_theme(e1, e2, e2name)
else if (is.ggplot(e1))
add_ggplot(e1, e2, e2name)
}
Besides, add_theme
, what you're interested in is is add_ggplot
which can be accessed with ggplot2:::add_ggplot
. The latter - a long yet very organized function - reveals more "cascading" functions to dispatch what's meant to be added.
That being said, R "knows" when using "+" on an object of class gg
which function to apply (because of S3 classes). You can find the starting point in ggplot2
GitHub repos, in the ggproto.R
on which I think most of ggplot2
behaviour depends on.
Is that what you're looking for?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…