R 如何控制SPAT'中的像素颜色;苔丝?

R 如何控制SPAT'中的像素颜色;苔丝?,r,spatstat,R,Spatstat,我在心形中生成随机点的镶嵌,我很难弄清楚如何控制绘图中像素的颜色。我认为当plot(tess)(在本例中)生成图像值的绘图时,我可以通过在颜色渐变中指定相同数量的颜色来控制它们,但事实并非如此 library(spatstat) t <- seq(from = 2*pi, to = 0.001, length.out = 1500) x <- 16*sin(t)**3 y <- 13*cos(t) - 5*cos(2*t) - 2*cos(3*t) - cos(4*t) #h

我在心形中生成随机点的镶嵌,我很难弄清楚如何控制绘图中像素的颜色。我认为当
plot(tess)
(在本例中)生成图像值的绘图时,我可以通过在颜色渐变中指定相同数量的颜色来控制它们,但事实并非如此

library(spatstat)

t <- seq(from = 2*pi, to = 0.001, length.out = 1500)
x <- 16*sin(t)**3
y <- 13*cos(t) - 5*cos(2*t) - 2*cos(3*t) - cos(4*t) #heart equation taken from wolfram http://mathworld.wolfram.com/HeartCurve.html.
heart_win <- owin(poly = cbind(x,y)) #note - not self enclosed

#random sample of points within heart
points <- rpoint(100, win = heart_win)
tess <- dirichlet(points)
plot(tess, main = ' ')

#color for 100 values
norm_palette <- colorRampPalette(c("white","red"))
plot(tess, main = ' ', col=norm_palette(100), valuesAreColours = FALSE)
库(spatstat)

t即使我不给我的妻子送礼物,我今天也不会送礼物,你可以试试这个:

 plot(tess$image,col=norm_palette(100))

即使我今天不给我妻子送礼物,也不会送礼物,你可以试试这个:

 plot(tess$image,col=norm_palette(100))

您没有调用tess对象中的结果图像。只需将绘图调用更改为:

plot(tess$image, main="", col=colorRampPalette(c("white","red"))(tess$n), valuesAreColours=FALSE)

您没有在tess对象中调用结果图像。只需将绘图调用更改为:

plot(tess$image, main="", col=colorRampPalette(c("white","red"))(tess$n), valuesAreColours=FALSE)

啊,谢谢你!多亏了agstudy to(据我所知,几乎是同步的答案)。我会把你的名字标为答案,只是为了传播名声和财富。@AndyW是的!和+1这是R的财富声誉(甚至我打败了他几秒钟:)啊,谢谢你!多亏了agstudy to(据我所知,几乎是同步的答案)。我会把你的名字标为答案,只是为了传播名声和财富。@AndyW是的!而+1则是R的声誉财富(甚至我也以几秒之差击败了他:)