有没有办法在 'spatstat' 包中使圆盘图的多边形边界不可见?

Is there a way to render invisible the polygonal boundary of a disc plot in the 'spatstat' package?

这是情节。我想去掉光圈的黑线

我相信这些图片很容易理解我想做什么。但我真的不知道该怎么做。任何帮助将不胜感激。

但是,我希望它看起来像下面这样:

这是我的代码:

library(spatstat.data)
library(nlme)
library(rpart)
library(spatstat)

repelled_points <- function(n, r_circle, r_clash) {
        container_x <- numeric(n)
        container_y <- numeric(n)
        j <- i <- 1
        while(i <= n)
        {
                j <- j + 1
                if(j == 100 * n) stop("Cannot accommodate the points in given space")
                x <- runif(1, -1, 1)
                y <- runif(1, -1, 1)
                if(x^2 + y^2 > 1) next
                if(i > 1) {
                        dist <- sqrt((x - container_x[seq(i-1)])^2 + (y - container_y[seq(i-1)])^2)
                        if(any(dist < r_clash)) next
                }
                container_x[i] <- x
                container_y[i] <- y
                i <- i + 1
                j <- 1
        }
        `class<-`(list(window = disc(centre = c(0, 0), radius = r_circle),
                       n = n, x = container_x * r_circle,
                       y = container_y * r_circle, markformat = "none"), "ppp")
}
dots <- repelled_points(18, 1, 0.35)
plot(dots, type="n")
points(dots$x[1:4], dots$y[1:4], pch=15, col="chartreuse3", cex=6)
points(dots$x[5:8], dots$y[5:8], pch=15, col="chartreuse3", cex=6)
points(dots$x[9:13], dots$y[9:13], pch=17, col="chartreuse", cex=6)
points(dots$x[14:18], dots$y[14:18], pch=17, col="chartreuse", cex=6)

谢谢!

您可以使用 lty = 0

绘图
plot(dots, type="n", lty = 0)
points(dots$x[1:4], dots$y[1:4], pch=15, col="chartreuse3", cex=6)
points(dots$x[5:8], dots$y[5:8], pch=15, col="chartreuse3", cex=6)
points(dots$x[9:13], dots$y[9:13], pch=17, col="chartreuse", cex=6)
points(dots$x[14:18], dots$y[14:18], pch=17, col="chartreuse", cex=6)

您的函数 repelled_points 创建点模式(spatstat 包中 class "ppp" 的对象)。要了解如何绘制它,请阅读 plot.ppp 的帮助。对于 select 个子集,请阅读 [.ppp.

的帮助
dots <- repelled_points(18, 1, 0.35)
plot(Window(dots), type="n", main="")
plot(dots[1:4], pch=16, cols="chartreuse3", cex=6, add=TRUE)

第 2 行使用 plot.owin,第 3 行使用 plot.ppp

在此代码中,我假设您特别希望使用指定参数绘制模式中的前 4 个点。

更常见的是,人们希望用不同的图形符号来表示具有不同“属性”的点。也许这些点被 class 分为几种不同的类型,类型 1 的点应该总是用正方形绘制,类型 2 用三角形绘制,等等。在 spatstat 中,点的属性将被编码作为点图案的“标记”。然后,您可以将上面的三行代码替换为调用 plot.ppp 的一行,其中包含将标记映射到符号所需的图形信息。请参阅 plot.ppp.

帮助中的示例

有关详细信息,请参阅 spatstat book 中的第 4 章。