Angle of facet labels when using strip.position

226 views
Skip to first unread message

Daniel Backenroth

unread,
Feb 9, 2017, 8:36:14 AM2/9/17
to ggplot2
Hi-

I'm creating a plot where I am using strip.position to adjust the position of facet labels.  I find that when I do this, the angle argument in theme(strip.text=element_text(angle=*)) no longer has any effect on the rotation of the labels. 

Here's a minimal example: 

MinimalExample <- function(angle){
  df <- data.frame(x=rnorm(1000), y=as.factor(sample(1:2, 1000, replace=T)))
  library(ggplot2)
  ggplot(df, aes(x=x)) + geom_histogram() + facet_wrap(~y, ncol=1, strip.position="left") + theme(strip.text = element_text(size = 12, angle=angle, color="blue")) + ggtitle(paste0("Angle:", angle))
  ggsave(paste0(angle, ".pdf"))
}

I'm attaching the result for angle=0 and for angle=90.  They look the same.  Does anybody know a way I can rotate these strip labels?  

Thanks very much,
Daniel
90.pdf
0.pdf

Olivia

unread,
Feb 9, 2017, 5:18:08 PM2/9/17
to ggplot2
I can reproduce the problem using your example code. On my computer I can fix it by specifying strip.text.y instead of the more general strip.text.  I've found the same problem with minor gridlines in plots - you need to specify any changes in panel.grid.minor.y and panel.grid.minor.x.

Cheers

Olivia

Daniel

unread,
Feb 10, 2017, 2:39:45 AM2/10/17
to ggplot2
Thank you Olivia, that worked!!
Reply all
Reply to author
Forward
0 new messages