问题
I am trying to add the species names to the rankabuncomp
plot. I tried to add specnames = T
to the rankabundance
function but I get an error. Please help me work around this problem. Thanks a lot.
library(vegan)
library(BiodiversityR)
data(dune.env)
data(dune)
RankAbun.1 <- rankabundance(dune)
RankAbun.1
rankabunplot(RankAbun.1,scale='abundance', addit=FALSE, specnames=c(1,2,3))
rankabuncomp(dune, y=dune.env, factor='Management', scale='proportion', legend=FALSE)
#to add specnames
rankabuncomp(dune, y=dune.env, factor='Management', specnames=c(1,2,3), scale='proportion', legend=FALSE, labels=FALSE)
回答1:
BiodiversityR::rankabuncomp
explicitly disallows adding species names. This is hardcoded in the function and cannot be changed without editing the function (look for specnames = NULL
in rankabunplot()
calls). The help page does not give specnames
argument to rankabuncomp
so that this is also documented. I can understand this decision: rankabuncomp
draws several lines in one graph, and often these are so similar that species names would overwrite each other and the plot becomes unreadable.
To add the lines, you either need edit the function or you must use a series of rankabunplot
commands to overlay graphs in one plot. Here is an example how to do that with the dune
data:
library(BiodiversityR)
data(dune, dune.env)
## list of models
mods <- with(dune.env, lapply(levels(Management), function(lev)
rankabundance(dune, dune.env, 'Management', lev)))
## level 4 seems to be most extreme: draw it first
rankabunplot(mods[[4]],scale='abundance', addit=FALSE, specnames=c(1,2,3))
## add the rest
## change colour etc to separate the lines if wished
rankabunplot(mods[[3]],scale='abundance', addit=TRUE, specnames=c(1,2,3))
rankabunplot(mods[[2]],scale='abundance', addit=TRUE, specnames=c(1,2,3))
rankabunplot(mods[[1]],scale='abundance', addit=TRUE, specnames=c(1,2,3))
The resulting plot is not very readable. If you use proportional scaling of y-axis, it becomes even less readable. However, you can do it.
来源:https://stackoverflow.com/questions/43859839/how-to-add-specnames-to-rankabuncomp