线性判别分析图

时间:2013-11-25 15:12:24

标签: r plot

如何将样本ID(行号)作为标签添加到此LDA图中的每个点?

library(MASS)
ldaobject <- lda(Species~., data=iris)
plot(ldaobject, panel = function(x, y, ...) points(x, y, ...),
     col = as.integer(iris$Species), pch = 20)

1 个答案:

答案 0 :(得分:4)

您可以在面板功能中使用text

library(MASS)
ldaobject <- lda(Species~., data=iris)
plot(ldaobject, 
     panel = function(x, y, ...) {
       points(x, y, ...)
       text(x,y,labels=seq_along(x),...) ## You change labels here 
      }
      ,
     col = as.integer(iris$Species), pch = 20)

enter image description here