In R 2.13.1 / ggplot2 0.8.9, I'm trying to add points onto a geom_tile layer. This example reproduces the error.
volcano3d <- melt(volcano)
names(volcano3d) <- c("x", "y", "z")
pts <- data.frame(a=runif(10,0,80), b=runif(10,0,60))
v <- ggplot(volcano3d, aes(x, y, z = z))
v + geom_tile(aes(fill = z))
# works fine
v + geom_tile(aes(fill = z)) + geom_point(data=pts, aes(x=a, y=b))
# Error in eval(expr, envir, enclos) : object 'z' not found
Any idea on what is wrong?
either unmap the z aesthetics with
v + geom_tile(aes(fill = z)) + geom_point(data=pts, aes(x=a, y=b,z=NULL) )
or simply remove it from the first ggplot call
v <- ggplot(volcano3d, aes(x, y))
v + geom_tile(aes(fill = z)) + geom_point(data=pts, aes(x=a, y=b))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With