I'd like to add a point to an existing filled.contour
plot, using the following code:
MyFunction <- function(x,y){
return(dnorm(sqrt(x^2+y^2)))
}
wrapper <- function(x, y, my.fun, ...) {sapply(seq_along(x), FUN = function(i) my.fun(x[i], y[i], ...))}
meshstep <- 0.5
x<- seq(-20,20,meshstep)
y <-seq(-20,20,meshstep)
z <- outer(x,y,FUN = wrapper, my.fun=MyFunction)
filled.contour(x,y,z, col=rev(heat.colors(n=20, alpha=0.7)), nlevels=15)
points(0,0)
I'm pretty surprised that points(0,0)
didn't put a point into the origin of the plot, but roughly located at x=10,y=0. Also, locator()
seems to be prompting coordinates with respect to that 'new' coordinate system as well. Why is that?