You almost have it. When you call
plot(rqss_model, bands=TRUE, add=TRUE, rug=FALSE, jit=FALSE)
The function helps a lot to return the constructed data. All we do is capture a data frame. First, a little tweaking of your function, return the data in a reasonable way.
plotfigs = function(df) { rqss_model = rqss(df$MeanEst ~ qss(df$N)) band = plot(rqss_model, bands=TRUE, add=TRUE, rug=FALSE, jit=FALSE) data.frame(x=band[[1]]$x, low=band[[1]]$blo, high=band[[1]]$bhi, pol=unique(df$polarization)) }
Then call the function and condense
figures = lapply(split(dd, as.factor(dd$polarization)), plotfigs) bands = Reduce("rbind", figures)
Then use geom_ribbon to build
## We inherit y and color, so have to set them to NULL fig + geom_ribbon(data=bands, aes(x=x, ymin=low, ymax=high, y=NULL, color=NULL, group=factor(pol)), alpha=0.3)