ggplot2 自定义轴缩放

ggplot2 custom axis scaling

我试图在 y 轴上绘制 Z 分数,在 x 轴上绘制位置。 x 轴是连续的并且很长,z 为 'interesting' 即 > 2 的区域相对较小。我想分割轴,删除 Z 离 0 不远的长区域,然后只绘制直接Z > 2 附近的区域。根据我的数据,仓位长度为 200000,只有大约 2000 个仓位具有有趣的 z 分数。这是我的 df 的样子;

 Position,Region,Height,Z
 3,orf1,10,0
 4,orf1,10,0.1
 5,orf1,10,0.1
 10,orf2,10,0
 11,orf2,10,-3
 12,orf2,10,-3
 16,orf3,10,0.1
 17,orf3,10,0.1
 18,orf3,10,0.1

 t1 <- ggplot(test, aes(x=Position, y=Z, colour=Z)) +
 geom_point(stat='identity') + ylim(-5,5) + 
 theme(legend.position='none') + scale_x_discrete(limit = c(0,5,8,15))

轴仍然是完整绘制的。如果我不想绘制位置 6-10 和 13-15,我该如何在 x 轴上进行绘制?谢谢

基于 lukeA 的评论 – 带有自由 x 轴的多面图。缺点是所有子图都具有相同的大小。

require(ggplot2)

d <- read.table("clipboard",sep=",",header=T)
ggplot(d,aes(x=Position,y=Z)) 
  + geom_line() 
  + facet_grid(. ~ region,scales="free_x")