0

I want to change strip text positions for all 8 symptoms in the ggplot2. I have tried different angles (0,90,180,270,360) in strip.text.y option but it did not flip labels from the vertical position.

p = ggplot(data=RR_data,
           aes(x = Group,y = LikelihoodRatio, ymin = LowerLimit, ymax = UpperLimit))+
  geom_hline(yintercept=1,linetype=2)+
  geom_pointrange(aes(col=Group))+
  xlab('Symptom')+ guides(colour = guide_legend(reverse=T)) + ylab("Likelihood Ratio (95% Confidence Interval)")+
  geom_errorbar(aes(ymin=LowerLimit, ymax=UpperLimit,col=Group),width=0.1,cex=1)+ 
  facet_wrap(~Symptom,strip.position="left",nrow=22, scales = "free_y") +
  theme(plot.title=element_text(size=16,face="bold",angle = 180),panel.background = element_rect(fill="white", colour="Grey"),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank(),
        axis.text.x=element_text(face="bold"),
        axis.title=element_text(size=10,face="bold"),
        strip.text.y = element_text(hjust=0, vjust=1, angle=180,face="bold"),
        strip.background.y = element_rect(fill="white", colour="grey"))+
  coord_flip()
p

ggplot

  • 1
    I tried your code on the iris dataset and it works for me. Can you add a reproducible example of your dataset ? https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – dc37 Apr 02 '20 at 05:49

1 Answers1

5

I am afraid this is a bit of an undocumented case, but you could use strip.text.y.left. I've taken a standard dataset to illustrate the problem as I couldn't reproduce your code.

ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
  geom_point() +
  facet_wrap(~ Species, strip.position = "left") +
  theme(strip.text.y.left = element_text(angle = 45))

enter image description here

The issue is known at ggplot: https://github.com/tidyverse/ggplot2/issues/3888

teunbrand
  • 33,645
  • 4
  • 37
  • 63