我正在尝试将原始计数放入小程序中,但总是很混乱:
set.seed(123)
c<-c(2, 3.5, 5, 7.9, 8.8, 12.3)
x<-sample(c, 100, replace=T)
barplot(table(x))
text(c, table(x)+2, labels=as.character(table(x)))
Run Code Online (Sandbox Code Playgroud)

有人有什么建议吗?
您只需要确保其ylim足够大,以至于不会将任何文本放置在绘图区域之外,然后您需要在条形图的中间位置并将文本放置在此处。
set.seed(123)
c<-c(2, 3.5, 5, 7.9, 8.8, 12.3)
x<-sample(c, 100, replace=T)
b<-barplot(table(x),ylim=c(0,22))
text(x=b, y= table(x)+1, labels=as.character(table(x)))
Run Code Online (Sandbox Code Playgroud)

| 归档时间: |
|
| 查看次数: |
3137 次 |
| 最近记录: |