我在R. 上用partimat函数制作了一个情节。 但是,图片上的数据点正在破坏情节。无论如何要保持边界并从图像中删除点?另外,我想添加一个图例,将每个数字与它的颜色相关联。
以下是代码:
library(ElemStatLearn);
data(zip.train);
load(zip.train);
zipTrain=data.frame(zip.train);
x=zipTrain[,-1];
y=zipTrain[,1];
library(MASS)
model=lda(y~.,data=x)
projected.data=as.matrix(x)%*%as.matrix(model$scaling)
projected.data=as.data.frame(projected.data)
M1=projected.data
couleurs=c("aquamarine","blue","brown","chartreuse","cyan","darkgreen","darkorange","pink","gold","gray")
library(klaR)
Matrice=data.frame(X2=M1[,2],X1=M1[,1],Y=y)
partimat(x=Matrice[,-3], grouping=as.factor(Matrice[,3]), method="lda",
col.mean="gold", image.colors =couleurs,pre=200,display.points=FALSE)