简体   繁体   English

线性判别分析图

[英]Linear discriminant analysis plot

How can I add the sample ID (row number) as labels to each point in this LDA 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)

You can use text in the panel function: 您可以在面板功能中使用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)

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM