gpt4 book ai didi

r - 在线图周围插入边框

转载 作者:行者123 更新时间:2023-12-01 23:55:27 25 4
gpt4 key购买 nike

我正在通过 plot 函数绘制几种不同鱼类的领地。如何在地 block 周围插入边框以突出显示该领土?我目前使用的功能是:

  plot(c.tri1.1FG$x.position,c.tri1.1FG$y.position,ylim=c(80,120),xlim=c(110,180),xlab="X position", ylab="Y position", main=expression(paste("Mapped territories of different ", italic("C. trifascialis"), " individuals at the Far Gardens coral reef site")))
points(c.tri1.2FG$x.position,c.tri1.2FG$y.position)
points(c.tri1.3FG$x.position,c.tri1.3FG$y.position)
points(c.tri1.4FG$x.position,c.tri1.4FG$y.position)
points(c.tri1.4FG$x.position,c.tri1.5FG$y.position)

enter image description here

任何帮助将不胜感激

最佳答案

如果我没理解错的话,我认为你正在寻找一个凸包chull:

x <- rnorm(100,0,.2)
y <- runif(100,0,2)
pts <- cbind(x,y)
ch <- chull(pts) #Convex hull
plot(pts, asp=1)

enter image description here

polygon(pts[ch,])

enter image description here

编辑:如何使此解决方案适应您的数据

plot(c.tri1.1FG$x.position,c.tri1.1FG$y.position,ylim=c(80,120),xlim=c(110,180),xlab="X position", ylab="Y position", main=expression(paste("Mapped territories of different ", italic("C. trifascialis"), " individuals at the Far Gardens coral reef site")))
points(c.tri1.2FG$x.position,c.tri1.2FG$y.position)
points(c.tri1.3FG$x.position,c.tri1.3FG$y.position)
points(c.tri1.4FG$x.position,c.tri1.4FG$y.position)
points(c.tri1.5FG$x.position,c.tri1.5FG$y.position)

x <- c(c.tri1.1FG$x.position,c.tri1.2FG$x.position,c.tri1.3FG$x.position, c.tri1.4FG$x.position, c.tri1.5FG$x.position)
y <- c(c.tri1.1FG$y.position,c.tri1.2FG$y.position,c.tri1.3FG$y.position, c.tri1.4FG$y.position, c.tri1.5FG$y.position)
pts <- cbind(x, y)
ch <- chull(pts)
polygon(pts[ch,])

关于r - 在线图周围插入边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23979056/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com