我试图用%相似度替换树状图上的高度轴。我目前的代码是:
ABf.x<-as.matrix(ABflip)
hc<-hclust(dist(ABf.x),method="ward")
plot(hc,hang=-1,labels=ABf.x[,1])
plot(hc,main="", hang=-1,ylab="Similarity",axes=FALSE,labels=ABf.x[,1])
scale=seq(0,max(hc$height),by=10)
sequence<-as.integer(seq(1,max(hc$height)),by=10)
percent<-as.integer((sequence/max(hc$height)*100))
lines(x = c(0,0), y = c(0,max(hc$height)),type = "n")
axis(2,at=scale, labels=percent) 不需要刻度就能得出图电流,从而产生错误:
轴上的误差(2,at =比例尺,标签=百分比):'at‘和’标签‘长度不同,36 != 351
发布于 2015-04-17 20:02:32
使用虹膜数据集作为示例数据。你可以玩天平,让它在100而不是99的时候达到顶峰。
ABf.x<-as.matrix(iris)
hc<-hclust(dist(ABf.x),method="ward")
plot(hc,hang=-1,labels=ABf.x[,1])
plot(hc,main="", hang=-1,ylab="Similarity",axes=FALSE,labels=ABf.x[,1])
scale=seq(0, max(hc$height), by=10)
sequence<-as.integer(seq(1,(max(hc$height)), by=10)) #get sequence of heights from dendrogram
percent<-as.integer((sequence/max(hc$height)*100)) #Convert these to a percent of the maximum height
lines(x = c(0,0), y = c(0,max(hc$height)),type = "n")
axis(2,at=scale, labels=percent) 链接到结果:示例
https://stackoverflow.com/questions/29707672
复制相似问题