R直方图-减少y范围

R histogram-reducing y range

我正在尝试使用 r 绘制如下所示的图表,想知道是否有办法

1) 省略y值的下限,但仍从0开始。

2) 此外,如何用文本标记直方图中的每个条形而不是数值?

如有任何帮助,我将不胜感激。谢谢!

评论中值得一读的答案使用了我选择的 plotrix::gap.barplot 的相同示例,但我一直在研究那些“波浪线”:

require(plotrix)
twogrp<-c(rnorm(10)+4,rnorm(10)+20)
gap.barplot(twogrp, gap=c(8,16), xlab="Index", ytics=c(3,6,17,20),
                   ylab="Group values", main="Barplot with gap")
polygon(y=c( 7.5+c(-1,1)*.2*rep(1,length(twogrp)+2),  
             8.5+ c(-1,1)*.2*rep(1,length(twogrp)+2) ) ,
        x=c(0,seq_along(twogrp), rep(length(twogrp)+1, 2), # going to the right...
              rev(seq_along(twogrp)) ,0) ,                # and coming back to the left
        col="white", border="white")  # could also try border="lightblue"

plotrix 中还有一个 axis.break 函数,可以为您提供轴上的注释。您可以对绘图区域内的标签使用 text 函数。