I could not find a previous answer to this question, but I was unsure of exactly what to search, so it's quite possible that I missed something.
When I plot the following data.frame, I get exactly what you'd expect.
df <- data.frame(x = c(1:5), y = 2^c(1:5))
g <- ggplot(df, aes(x=x, y=y)) + geom_line()
g
The problem arises when I try to limit the range of the y-axis such that one of the line segments, (4, 16) to (5, 32), is only partially on the plot. ggplot does not show the portion of that line segment that would be on the plot; instead, it just entirely omits the line segment.
g <- ggplot(df, aes(x=x, y=y)) + geom_line() + scale_y_continuous(limits = c(0, 25))
What I would like is something that looks like this.
I know that I could break the final line segment into smaller pieces, but that seems like an inconvenient solution. There must be some way to make ggplot include the segment.