将标签添加到带条件的条形图顶部. [英] Add labels to top of barplot with condition.
本文介绍了将标签添加到带条件的条形图顶部.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个看起来像这样的条形图:
I have a barplot that looks like this:
我需要将名称添加到栏的顶部.但我只想标记水平 0.5 线以上的名称.
I need to add the names to the top of the bars. But I only wish to label the names that are above the horizontal 0.5 line.
我可以添加如下标签:
xx <- barplot(....)
text(xx, data$features, labels=data$features, pos=3, offset=.5)
但这当然会增加所有值.
But this of course adds all values.
推荐答案
What about :
What about :
set.seed(1)
y <- round(rnorm(10),1)
xx <- barplot(y)
yy <- y[y>.5]
xx <- xx[y>.5]
text(xx, yy, labels=yy, pos=3, offset=-1)
这篇关于将标签添加到带条件的条形图顶部.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文