在R中的条形图中的条形顶部添加数据标签

时间:2017-03-25 23:46:25

标签: r graphics

我只想在图表的每个条形图上添加数据值。我怎样才能做到最好?

SET

由于

1 个答案:

答案 0 :(得分:1)

您只需要添加正确的text语句。

par(mfrow=c(1,3))
BP = barplot(HOLD[,1] * 100, main="Infolettre", ylab="%", ylim=c(0, 100), las=1,  col=SEQUENTIAL)
text(BP, HOLD[,1]*100, labels=HOLD[,1]*100, pos=3)

BP = barplot(HOLD[,2] * 100, main="Promotion", ylab="%", ylim=c(0,100), las=1, col=SEQUENTIAL)
text(BP, HOLD[,2]*100, labels=HOLD[,2]*100, pos=3)

BP = barplot(HOLD[,3] * 100, main="Abonne", ylab="%", ylim=c(0,100), las=1, col=SEQUENTIAL)
text(BP, HOLD[,3]*100, labels=HOLD[,3]*100, pos=3)