r - Remove axis text from one facet -


i'm trying display 3 time series using facet_grid() , in order save space, i'm reducing panel spacing between them. problem vertical axis overlap want move right on plot in middle.

since seem impossible in ggplot2, i'm trying render every axis , remove editing gtable far not successful.

this minimal example:

library(ggplot2)  set.seed(123) df <- data.frame(expand.grid(x = 1:150, type = letters[1:3])) df$y <- df$x*0.016 + rnorm(150, sd = .5)  ggplot(df, aes(x, y)) + geom_line() +     facet_grid(type~.) +      theme(panel.spacing.y = unit(-3, "lines"), strip.text = element_blank()) +     scale_y_continuous(sec.axis = dup_axis(name = ""), name = "y") 

which produces this:

produced plot

and want delete each axis text this:

plot made gimp

thanks!

the solution assign nullgrob() relevant elements of gtable.

gt <- ggplotgrob(g) t <- gt[["grobs"]][[8]][["children"]][[2]]  # found grobs looking around table.  gt[["grobs"]][[8]][["children"]][[2]] <- nullgrob() gt[["grobs"]][[10]][["children"]][[2]] <- nullgrob() gt[["grobs"]][[12]][["children"]][[2]] <- nullgrob()  grid.newpage() grid.draw(gt) 

good plot


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -