I’m trying to use a function to annotate a ggplot graph, as in
ds <- tibble(A=runif(25)*pi,B=runif(25),C=runif(25))
p <- ggplot(ds)+geom_point(aes(x=A,y=B))
p+ggplot2::annotate(geom="function",fun=sin)
The above example does not add the required curve. My understanding is that this is the way annotate() should behave…
Of course I could use directly a geom_ :
p2 <- p+geom_function(fun=sin)
but – quite apart from the frustration at not being able to understand how to use annotate() – this would make my life more difficult, as I’m in fact doing things programmatically and it would help if everything was in annotations (it would avoid the need of a special case in the final code).
Thanks !