I\'m struggling to build a dual-axis plot based on ggplot
objects. At baptiste\'s suggestion, I have broken down the problem into smaller parts. The present iss
A more natural strategy would be to use invisible geom_blank
layers, so that ggplot2 still trains the scales etc to build the plot but shows no data. Since you want to process already-formatted plots, however, you probably have to remove manually those grobs from the plot gTree. Here's an attempt,
library(gtable)
g <- ggplotGrob(p)
stripdata <- function(g){
keep <- grepl("border|grill",
names(g[["grobs"]][[4]][["children"]]))
g[["grobs"]][[4]][["children"]][!keep] <- NULL
g
}
grid.newpage()
grid.draw(stripdata(g))