weixin_46680200 2023-04-06 09:50 采纳率: 0%
浏览 71
已结题

R语言 SIBER包 如何修改community的线形和点型?

附上SIBER包:https://cran.r-project.org/web/packages/SIBER/vignettes/Introduction-to-SIBER.html

论文中看到不同的community可以用不同线型区分,并且点型也是非默认的

img

我自己做出来的只能将group用颜色区分,community是同色同线形

img


Shape <- read.csv('D:/Research/SIBER_2.1.6/mydata/Shape.csv', header = T )
siber.example <- createSiberObject(Shape)

community.hulls.args <- list(palette(c("#81b8df","#fe827e")), lty = 1, lwd = 1)
group.ellipses.args  <- list(n = 100, p.interval = 0.40, lty = c("solid"), lwd = 3)
group.hull.args      <- list(lty = 5, col = "gray60")

par(mfrow=c(1,1))
plotSiberObject(siber.example,
                ax.pad = 2, 
                hulls = F, community.hulls.args, 
                ellipses = T, group.ellipses.args,
                group.hulls = T, group.hull.args,
                bty = "o",
                iso.order = c(1,2),
                xlab = expression({delta}^13*C~'\u2030'),
                ylab = expression({delta}^15*N~'\u2030'),
                x.limits = c(-21,-10),
                y.limits = c(4,20)
                )

直接在community.hulls.args后加pch和lty没有反应,请问各位这种情况要怎么改?

  • 写回答

5条回答 默认 最新

  • 百晓生2023 2023-04-06 09:55
    关注
    该回答引用ChatGPT
    要修改SIBER包中的community线形和点型,需要在创建SIBER对象之前使用自定义参数来指定线形和点型的样式。使用`createSiberObject()`函数中的`community.args`参数来指定线形,使用`community.tags.args`参数来指定点型。例如,以下代码可以用虚线和星号来表示两个不同的community:

    r
    library(SIBER)

    # 读入数据
    Shape <- read.csv('D:/Research/SIBER_2.1.6/mydata/Shape.csv', header = TRUE)

    # 定义community的线形和点型
    community.hulls.args <- list(palette(c("#81b8df","#fe827e")), lty = c(2,3), lwd = 2)
    community.tags.args <- list(pch = c(8,3), cex = 1.5)

    # 创建SIBER对象
    siber.example <- createSiberObject(Shape,
    community.args = community.hulls.args,
    community.tags.args = community.tags.args)

    # 绘制SIBER图
    plotSiberObject(siber.example,
    ax.pad = 2,
    hulls = FALSE,
    ellipses = TRUE,
    group.ellipses.args = list(n = 100, p.interval = 0.40, lty = "solid", lwd = 3),
    group.hulls = TRUE,
    group.hull.args = list(lty = 5, col = "gray60"),
    bty = "o",
    iso.order = c(1,2),
    xlab = expression({delta}^13*C ~ '\u2030'),
    ylab = expression({delta}^15*N ~ '\u2030'),
    x.limits = c(-21,-10),
    y.limits = c(4,20))


    在指定参数时,需要注意以下几点:

    - `community.hulls.args`和`community.tags.args`都是列表,用于指定多个community的样式。
    - `lty`和`pch`都需要用向量指定每个community的样式。例如,`lty = c(1,2)`表示第一个community使用实线,第二个community使用虚线;`pch = c(1, 2)`表示第一个community使用圆圈,第二个community使用三角形。
    - 如果只有一个community,则可以使用单个参数,例如`lty = 2`表示使用虚线。

    此外,如果试图在`community.hulls.args`后直接添加`pch`和`lty`参数,则会因为参数名称不匹配而出现错误。应该将它们添加到新的列表中。
    评论

报告相同问题?

问题事件

  • 系统已结题 4月14日
  • 创建了问题 4月6日