从以下代码开始:
library(vegan)
data(dune)
data(dune.env)
Ordination.model1 <- cca(dune ~ Management,dune.env)
plot1 <- plot(Ordination.model1, choices=c(1,2), scaling=1)
我得到了一个包含遗址,物种,质心和双箭头的情节。我想建立一个只有点描绘的网站和带有自定义标签的箭头的情节。 到目前为止,我有:
colvec <- c("red", "green", "blue")
plot(Ordination.model1, type="n", scaling=1)
with(dune.env, points(Ordination.model1, display ="sites", col=colvec[Use], scaling=1, pch =16, bg = colvec[Use]))
我被困在了如何把箭放进去。提前谢谢!
答案 0 :(得分:2)
您可以使用文字添加箭头。我无法使用您的代码,因为我不断收到错误,但这是一个基本的例子,可以做你想要的。我是从R Help: CCA Plot 拿走的 添加文本后,箭头应显示。
require(vegan)
data(varespec)
data(varechem)
vare.cca <- cca(varespec ~ ., data = varechem)
plot(vare.cca, display = c("sites","species"), scaling = 3)
text(vare.cca, scaling = 3, display = "bp")
以下是带有labels参数的示例:
## S3 method for class 'cca':
text((x, display = "sites", labels, choices = c(1, 2),
scaling = "species", arrow.mul, head.arrow = 0.05, select, const,
axis.bp = TRUE, correlation = FALSE, hill = FALSE, ...))
标签: 要使用的可选文本而不是行名称: Plot or Extract Results of Constrained Correspondence Analysis or Redundancy Analysis
答案 1 :(得分:0)
我能够重命名箭头:下面是完整的代码。
library(vegan)
data(dune)
data(dune.env)
Ordination.model1 <- cca(dune ~ Management,dune.env)
summary(Ordination.model1) # Lets you see the current biplot labels in the output.
colvec <- c("red", "green", "blue", "orange")
plot(Ordination.model1, type="n", scaling=1)
with(dune.env, points(Ordination.model1, display ="sites", col=colvec[Management],scaling=1, pch =16, bg = colvec[Management]))
labl <- c("HF", "NM", "SF") # new labels. Need to be in the same order as the old biplot labels.
text(Ordination.model1, display="bp", scaling=1, labels=labl)