我正在尝试使用称为“ factoextra”的R库生成一些轮廓。 不幸的是,我最终遇到了一个问题。 让我们看下面的示例,使用“ iris”数据集。
library(factoextra)
library(cluster)
set.seed(123)
data("iris")
iris.scaled <- scale(iris[, -5])
# K-means clustering
km.res <- kmeans(iris.scaled, 3, nstart = 2)
# Visualize silhouhette information
sil <- silhouette(km.res$cluster, dist(iris.scaled))
fviz_silhouette(sil)+
scale_fill_discrete(labels=c("a","b","c"))
如您所见,图例重复出现,显示“ a”,“ b”,“ c”,然后显示“ 1”,“ 2”,“ 3”。有没有办法只显示“ a”,“ b”,“ c”?
答案 0 :(得分:1)
您只需删除@Data
@Entity
@Table(name = "professions")
public class Profession extends BasicEntity {
@Id
@Column(name = "profession_id", unique = true)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "profession_key_generator")
@SequenceGenerator(name = "profession_key_generator", allocationSize = 1)
private int profession_id;
@Column(name = "profession_rus_title", unique = true)
private String rusTitle;
@Column(name = "profession_eng_title", unique = true)
private String engTitle;
@Override
public Integer getId() {
return profession_id;
}
public Profession(String rusTitle, String engTitle){
this.rusTitle = rusTitle;
this.engTitle = engTitle;
}
public Profession(){
}
}
指南:
color
如果您查看源代码,则可以看到控制映射的以下行:
sil <- silhouette(km.res$cluster, dist(iris.scaled))
fviz_silhouette(sil)+
scale_fill_discrete(labels=c("a","b","c"))+
guides(col=FALSE)
设置离散填充并删除颜色会产生预期的图。
结果: