我使用R中的bipartite包中的plotweb函数来表示向量关系。我有一个关于颜色的问题:我想给我上面的每个盒子一个不同的颜色,与它离开的盒子具有相同的颜色。
这是我的代码,x是一个联想表。我试图根据列的总和将颜色归因于交互:例如,如果第一列有3个交互,我的前3行具有相同的颜色,但它不起作用……plotweb似乎随机地给颜色赋值。
bipart <- function(x) {
somme <- data.frame(margin.table(x,2))
names(somme) <- c("eff")
write.table(somme$eff, "essai.txt", sep = ";", row.names = FALSE, col.names = FALSE)
effP <- scan(file = "essai.txt")
colP <- rep(rainbow(length(effP)), effP)
plotweb(x,
method = "normal", arrow="up.center",
col.high = colP,
col.low = "black",
col.interaction= colP,
bor.col.interaction =colP,
bor.col.high=colP,
bor.col.low="black",
high.lablength = NULL, low.lablength = NULL, text.rot=90,
text.high.col="black", text.low.col="black",
low.lab.dis=0)
}和我数据的一部分:
atricapillum basilicorne blandulum carinatum confusum dubium
Cyperaceae 1 1 1 0 1 1
Juncaceae 1 1 0 1 1 0
Plantaginaceae 0 0 0 0 1 0
Poaceae 1 0 0 0 0 0
Typhaceae 1 0 0 0 0 0谢谢您抽时间见我!
发布于 2018-05-21 00:24:45
我终于知道该怎么做了!
bipart <- function(x) {
colP = rainbow(length(x[x,]))
plotweb(x,
method = "normal", arrow="up.center",
col.high = colP,
col.low = "black",
col.interaction= colP,
bor.col.interaction =colP,
bor.col.high=colP,
bor.col.low="black",
high.lablength = NULL, low.lablength = NULL,
text.rot=90,
text.high.col="black", text.low.col="black",
low.lab.dis=0}https://stackoverflow.com/questions/50436719
复制相似问题