Force y axis to start at 0, insert "break", AND have a large y axis using ggplot2 [duplicate]

Plotting discontinuous axis is made difficult for a reason, that reason being that you should avoid doing it whenever possible. While I disagree with your reviewers, you can get down and dirty with the underlying grid graphics if you truly want a y-axis break.

First make your plot. The only thing I added was y-axis formatting and an axis line theme. We'll just label the bottom tick with "0".

plt <- ggplot(data = quad2,
       aes(x, predicted, group = group)) +
  geom_point(aes(shape = group), size = 6) +
  scale_shape_manual(values=c(19, 1)) +
  geom_line(size = 2,
            aes(linetype = group),
            color = "black") +
  scale_linetype_manual(values = c("solid", "dashed")) +
  geom_linerange(size = 1,
                 aes(ymin = predicted - conf.low,
                     ymax = predicted + conf.high),
                 color = "black",
                 alpha = .8) +
  geom_segment(aes(xend = x,
                   yend = ifelse(group == "Control", conf.high, conf.low)),
               arrow = arrow(angle = 90), color = "red")+
  labs(x = "Time",
       y = expression(bold("QUAD Volume (cm"^"3"*")")),
       linetype = "",
       shape = "") + #Legend title
  scale_y_continuous(limits =c(1400, 2000),
                     breaks = seq(1400, 2000, by = 200),
                     labels = c(0, seq(1600, 2000, by = 200)),
                     expand = c(0,0,0.05,0)) +
  theme(axis.line = element_line())

Then, we'll make this into a gtable and grab the y-axis line:

gt <- ggplotGrob(plt)

is_yaxis <- which(gt$layout$name == "axis-l")
yaxis <- gt$grobs[[is_yaxis]]

# You should grab the polyline child
yline <- yaxis$children[[1]]

Now we can edit the line as we see fit:

yline$x <- unit(rep(1, 4), "npc")
yline$y <- unit(c(0, 0.1, 1, 0.15), "npc")
yline$id <- c(1, 1, 2, 2)
yline$arrow <- arrow(angle = 90)

Place it back into the gtable object and plot it:

yaxis$children[[1]] <- yline

gt$grobs[[is_yaxis]] <- yaxis

# grid plotting syntax
grid.newpage(); grid.draw(gt)      

enter image description here

You can make stylistic choices at the line editing step as you see fit.


To my knowledge ggplot2 doesn't support axis breaks. There is a solution here with facet_grid.