我想在 R 中绘制一些物种积累曲线,这些曲线可以以灰度格式相互叠加,同时易于解释。 Here是我想要输出的绘图类型的链接,其中多边形具有不同类型的灰色和一定程度的透明度,线条具有不同的lty值。一些示例数据:
df1 <- as.data.frame(matrix(sample(0:1, 3*10, replace=TRUE), ncol=3))
df2 <- as.data.frame(matrix(sample(0:2, 4*10, replace=TRUE), ncol=4))
library(vegan)
spec1 <- specaccum(df1)
spec2 <- specaccum(df2)
这是迄今为止我所掌握的plot
(不是很好的示例数据,但基本原理是正确的):
plot(spec2, ci.type = "polygon", ci.lty = 0, ci.col = "grey")
plot(spec1, ci.type = "polygon", ci.lty = 0, ci.col = "gray50",add= TRUE)
当我尝试更改 lty
时,它显示:
Error in polygon(c(xaxvar, rev(xaxvar)), c(x$richness - ci * x$sd, rev(x$richness + : formal argument "lty" matched by multiple actual arguments.
我不知道如何克服这个问题。任何帮助将不胜感激。
最佳答案
对于您的数据,您需要将 ci.col
参数更改为 rgb()
颜色规范,并带有 alpha
值以实现透明度( see here for details ,请记住,根据文档,并非所有设备都支持透明度):
plot(spec2, ci.type = "polygon", ci.lty = 0, ci.col = rgb(0, 0, 0, 0.5))
plot(spec1, ci.type = "polygon", ci.lty = 1, ci.col = rgb(.5, .5, .5, 0.5),add= TRUE).
这将为您提供以下情节:
关于r - 叠加不同物种积累图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31747150/