我正在心形内生成随机点的镶嵌,我很难弄清楚如何控制图中像素的颜色。我认为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)
这会产生下面的图像:
是的,我就是那种直到(不要评判我)才把他的妻子当作情人节礼物的人!