First, I initialize the data
set.seed(1)
x <- runif(10000,17,18)
yone <- x+1/4
ytwo <- x-1/4
df <- data.frame(x,yone,ytwo)
Then I create the plot
ggplot(df,aes(x=x)) +
geom_line(aes(y=yone)) +
geom_line(aes(y=ytwo)) +
geom_ribbon(aes(ymin = yone, ymax = ytwo),fill='blue',alpha=0.5) +
geom_hline(yintercept=17) +
geom_vline(xintercept=17) +
geom_hline(yintercept=18) +
geom_vline(xintercept=18) +
theme_bw() +
scale_x_continuous(expand=c(0,0), limits = c(17,18)) +
scale_y_continuous(expand=c(0,0), limits = c(17,18))
There are two trapezoid shaped areas between the lines that are not shaded. I want it to look like:
That area is filled in properly if I dont use scale_x_continuous
and scale_y_continuous
to restrict the limits of the plot, but that's a necessity.