Skip to content

Instantly share code, notes, and snippets.

@baptiste
Created February 17, 2017 20:11
Show Gist options
  • Save baptiste/c2191c3f8426889efa2352022ae90b85 to your computer and use it in GitHub Desktop.
Save baptiste/c2191c3f8426889efa2352022ae90b85 to your computer and use it in GitHub Desktop.
library(ggplot2)
library(grid)
p <- qplot(1,1) + labs(y="y title") +
theme(axis.title.y = element_text(angle = 0))
g <- ggplotGrob(p)
id <- which(g$layout$name == "ylab-l")
h <- grobHeight(g$grobs[[id]]) # doesn't seem to be defined
pos <- g$layout[id, "t"]-1
g <- gtable::gtable_add_rows(g, unit(2,"line"), pos = pos)
g$layout[id, c("l", "r", "t", "b")] <- g$layout[id, c("l", "r", "t", "b")] + c(1,1,-1,-1)
grid.newpage()
grid.draw(g)
@bhive01
Copy link

bhive01 commented Feb 17, 2017

@baptiste
Copy link
Author

oh, didn't see that. That's the problem with people posting questions on random forums, duplication of efforts, and difficulty in finding them. I usually say no to anything that's not on SO these days, I guess that's a good reminder to stick to the rule

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment