如何在纯素食包的Bray nmds分析中添加椭圆

时间:2019-03-18 03:34:29

标签: r ellipse vegan

我已经用纯素包装画了点图,但我想圈出经过类似处理的物种。如图所示,3种处理的3种颜色。我也想圈出他们。

这是我的代码。

loop:
add $t2, $zero, $zero     #index of the string
load: 
la $s0, array              #load address of array to s0
la $t0, list               #load adress of the string
sll $t3, $t2, 1            #multiply string index by 2 to skip spaces
sll $t4, $s1, 2            #multiply index of array by 4 for size of word
addu $t0, $t0, $t3         #position string
addu $s0, $s0, $t4         #position array
lbu $t1, 0($t0)            #load byte of the string to t1
addiu $t1, $t1, -48        #convert char to integer
sb $t1, 0($s0)             #store byte into the array
addi $t2, $t2, 1           #increment index of string by 1
addi $s1, $s1, 1           #increment index of array by 1
blt $t2, 4, load           #if the index of the string is less than 4, load the next character
li $v0, 11                 #printing first input as integers from here
addi $a0, $zero, 0xA
syscall
li $v0, 4                  #call for print string
la $a0, row1               #load string to be printed
syscall
li $v0, 1
lb $a0, -12($s0)
syscall
li $a0, 32
li $v0, 11                 # syscall number for printing character
syscall
li $v0, 1
lb $a0, -8($s0)
syscall
li $a0, 32
li $v0, 11                 # syscall number for printing character
syscall
li $v0, 1
li $a0, 32
li $v0, 11                 # syscall number for printing character
syscall
li $v0, 1
lb $a0, 0($s0)
syscall
exit:
li $v0, 10
syscall

Here is my current figure. [我的数据

library(vegan)
library(MASS)
library(readxl)



bray1 <- read_excel("bray1.xlsx")

cols <- c("red", "blue","blue", "green","green","red","blue","green","green","red","red","blue")

row.names(bray1) <- c("SI1", "SII0", "SI0", "SII2", "SI2", "SII1", "SIII0", "SIV2", "SIII2", "SIV1", "SIII1", "SIV0")

bcdist <- vegdist(bray1, "bray")

bcmds <- isoMDS(bcdist, k = 2)


plot(bcmds$points, type = "n", xlab = "", ylab = "")

text(bcmds$points, dimnames(bray1)[[1]],col = cols,size=10)

1 个答案:

答案 0 :(得分:1)

以下是基于dataEllipse包中car函数的几个替代方法。我对您的基本图形做了一些小的改动。我发现很难读取纯的“绿色”彩色文本,因此将其切换为“深绿色”。我更改了绘图限制,以便完整的椭圆出现在图片中。另外,您的text语句包含一个自变量sizetext没有参数size,因此我将其替换为cex来设置字体大小。

library(car)

Group = c(1,2,2,3,3,1,2,3,3,1,1,2)
cols <- c("red", "blue","blue", "darkgreen","darkgreen","red","blue",
    "darkgreen","darkgreen","red","red","blue")

在第一个版本中,我按照您的要求做了,标记了治疗组的椭圆形。

plot(bcmds$points, type = "n", xlab = "", ylab = "", 
    xlim=c(-0.8,0.8), ylim=c(-0.8,0.8), asp=1)
text(bcmds$points, dimnames(bray1)[[1]],col = cols, cex=0.8)
dataEllipse(bcmds$points[,1], bcmds$points[,2], factor(Group),
    plot.points=F, add=T, col=c("red", "blue", "green"),
    levels=rep(0.6, 3), center.pch=0, group.labels="", lwd=1)

Ellipses by outline

在第二个版本中,我没有使用椭圆的轮廓,而是使用透明的填充色来显示椭圆。

plot(bcmds$points, type = "n", xlab = "", ylab = "", 
    xlim=c(-0.8,0.8), ylim=c(-0.8,0.8), asp=1)
text(bcmds$points, dimnames(bray1)[[1]],col = cols, cex=0.8)
dataEllipse(bcmds$points[,1], bcmds$points[,2], factor(Group),
    plot.points=F, add=T, col=c("red", "blue", "green"),
    levels=rep(0.6, 3), center.pch=0, group.labels="", 
    lty=0, fill=TRUE, fill.alpha=0.04)

Ellipses filled with transparent color