r使轮廓充满

r使轮廓充满,r,ggplot2,geospatial,contour,R,Ggplot2,Geospatial,Contour,我试图用x、y和z值的数据表制作填充等高线图 library(ggplot2) x = 1:100 y = 1:100 z = 1:100 table = data.frame(x,y,z) ggplot() + geom_point() geom_polygon(data = table, aes(x = x, y = y, z=z, fill = ..fill.., group = ..piece..),

我试图用x、y和z值的数据表制作填充等高线图

library(ggplot2)
x = 1:100
y = 1:100
z = 1:100

table = data.frame(x,y,z)

ggplot() + geom_point()

  geom_polygon(data = table,
               aes(x = x, y = y, z=z,
                   fill = ..fill.., group = ..piece..), 
               stat = "density2d", alpha = .5)
如何使其不使用标高而使用z值填充轮廓

我想要像这样的东西:


您可能想要这样的东西,尽管它需要不同的数据:

x = rep(1:100,100)
y = rep(1:100,each = 100)
z = x + y

table = data.frame(x,y,z,f = z%/%10+1)

p <- ggplot(table, aes(x = x,y = y, z = z))

p + geom_tile(aes(fill = f))
x=rep(1:100100)
y=rep(1:100,每个=100)
z=x+y
表=数据帧(x,y,z,f=z%/%10+1)

p如果有的话,你的代码目前产生了什么?预期结果是什么?请查看
geom\u等高线的文档