首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在我的树状图的y轴上输出%的相似性?

如何在我的树状图的y轴上输出%的相似性?
EN

Stack Overflow用户
提问于 2015-04-17 19:18:02
回答 1查看 396关注 0票数 2

我试图用%相似度替换树状图上的高度轴。我目前的代码是:

代码语言:javascript
复制
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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-17 20:02:32

使用虹膜数据集作为示例数据。你可以玩天平,让它在100而不是99的时候达到顶峰。

代码语言:javascript
复制
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) 

链接到结果:示例

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29707672

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档