SplitBar <- function(p, Y1,Y2,Y3, Y0=0,R=c(1,1)){ Lay = c(rep("A",R[1]),rep("B",R[2])) layout="" for( i in Lay){ layout=paste(layout,i,sep="\n") } p1 <- p + coord_cartesian(ylim = c(Y2,Y3))+ theme(axis.text.x = element_blank(), axis.title = element_blank(), axis.ticks.x = element_blank(), legend.position = 'none', panel.grid = element_blank(), panel.border = element_blank(), axis.line.y = element_line(colour = "black")) p2 <- p + coord_cartesian(ylim = c(Y0,Y1))+ theme(title = element_blank(), plot.title = element_blank(), panel.grid = element_blank(), panel.border = element_blank(), axis.line = element_line(colour = "black")) p1/p2 + plot_layout(design = layout) }
SplitBar(p,450,99998,100011,0,c(1,10))
|