I know that making a shaded area between two y curves with the same x values is as follows:
geom_ribbon(data=dataframe,aes(ymin = y_lwr, ymax = y_upr), fill = "grey")
However, does anyone knows how we can plot the shaded area between two curves with different x values?
When the lower curve is defined by (x_lwr, y_lwr)
and the upper curve is defined by (x_upr, y_upr)
The full data set is supposed to generate a graph as follows:
The sample data and code I have is as follows:
> head(df)
y1 x1 y_lwr x_lwr y_upr x_upr
#> 1 11.60 67.01 4.97 86.28 14.54 58.17
#> 2 11.32 68.57 4.51 88.99 13.74 61.67
#> 3 10.76 71.63 4.15 91.29 13.00 64.74
#> 4 10.19 75.52 3.82 92.69 12.35 67.83
#> 5 9.91 77.33 3.60 94.19 11.71 70.84
#> 6 9.62 79.14 3.46 94.90 11.21 73.33
pltS <- ggplot(data=df, aes(x=df[,2], y=df[,1]))+
ylab("log(y)")+ xlab("x")
pltS <- pltS + geom_point(pch = 16, col="black", size=1)
# upper and lower bands
plt <- plt + geom_line(aes(x=df[,4], y=df[,3]), col="grey", size=1)
plt <- plt + geom_line(aes(x=df[,6], y=df[,5]), col="grey", size=1)
# x-axis & y-axis specifications
plt <- plt + theme(aspect.ratio=1)+
scale_y_continuous(trans = 'log10')+
annotation_logticks(sides="l")+
scale_x_continuous(labels = function(x) paste0(x, "%"))
plt