我正在用ggplot2
做一个等高线图,并且试图添加像this tutorial这样的标签。但是,始终会出现以下错误:
Error in geom_text_contour(aes(z = z)) : could not find function "geom_text_contour"
library(ggplot2)
x <- c(0,0,0,1,1,1,2,2,2,3,3,3)
y <- c(0,1,2,0,1,2,0,1,2,0,1,2)
z <- seq(0,11,1)
df <- data.frame(x,y,z)
ggplot(df, aes(x, y, z = z)) +
geom_tile(aes(fill = z)) +
geom_contour(colour = "white") +
geom_text_contour(aes(z = z))