使用 ggplot 在轴的末端剪切标记

Clip marks at the end of axis with ggplot

R version 3.1.1 (2014-07-10) Platform: i386-w64-mingw32/i386 (32-bit)

我正在使用 ggplot2 绘制直方图。由于我有大量尾部数据,我想在 ggplot 的 x 轴末尾使用 axis "clip marks" ,如下例所示。 (不是红色的 0.95 分位数,而是 x 轴末端的黑色小剪辑标记)

问题不是 Using ggplot2, can I insert a break in the axis? 中所问的轴内中断,而是轴末端的剪裁和添加标记,绘图的 reader 可以立即看到,观察到的数据超过了轴。此示例在 x 轴末端有两条倾斜的平行斜线。这就是我想在 ggplot 图上实现的。

require(plotrix)
x <- rbeta(10000, 1, 7)
hist(x, xlim=c(0,0.4))
axis.break(1,0.405)

是否有可能使用 ggplot 获得类似的轴折断标记?我有使用 geom_segment 的想法,但我没有得到任何好的解决方案,因为它总是取决于 x 和 y 轴值的比率。

ggplot()+
      geom_histogram(aes(x=x), binwidth = 0.05)+
      coord_cartesian(xlim = c(0, 0.45))

感谢您的帮助!

评论后编辑。更好?

ggplot()+  geom_histogram(aes(x=x), binwidth = 0.05, color = "grey30", fill = "white")+
  coord_cartesian(xlim = c(0, 0.405)) +
  theme_tufte() +
  labs(y = "Frequency") +
  annotate("text", x = 0.4, xend = 0.4, y = 0.01, yend = .99, colour = "red", label = "//", size =6)