Reputation: 125
I have a set of data predicted by a model. I'm plotting it with geom_tile().
df1 <- data.frame(x=rep(seq(0,10,by=.1),each=101),
y=rep(seq(10,20,by=.1),times=101))
df1$z <- ((.1*df1$x^2+df1$y)-10)/20
library("ggplot2")
ggplot(mapping=aes(x=x,y=y,size=5,color=z),data=df1)+
geom_point(size = 16, shape = 15)
ggplot(df1, aes(x, y, fill="blue",alpha = z)) + geom_tile()
How can I add some contour lines to it at specific values (e.g. z=0.9, 0.95, 0.99)? Alternatively, geom_tile can be changed to any suitable continuous / contour / raster plot function.
Upvotes: 0
Views: 1589
Reputation: 6496
ggplot(df1, aes(x, y, z = z, fill = z))+
geom_tile()+
geom_contour()
Upvotes: 1