Search code examples
rggplot2bar-chartvisualizationsubscript

Add subscript to bar chart title


I'd like to subscript the number "6" in my bar chart title- "PSII monomer, Cyt b6f". I've been trying with functions like expression and bquotebut doesn't seemed to work. Anybody enlighten me?

ggplot(data=summary_Lane3, mapping = aes(x = factor(time), y = rd, fill= gc))+
  geom_bar(stat = "identity", position = "dodge")+
  labs(title=expression("PSII monomer, Cyt b[6]f"),x= "Time (hr)",  y="Relative density", fill= "Growth conditions")+
  ylim(0,2.1)+
  geom_errorbar(aes(ymin=rd-se, ymax=rd+se), width=.5, position=position_dodge(width= 0.9))+
  stat_compare_means(data=Lane3, label="p.signif", label.y= 1.85, method="anova")+
  theme_bw()+
  theme(text = element_text(size = 15))

Solution

  • So, use this instead of the abovementioned (credit to rawr),

    labs(title=expression(paste("PSII monomer, Cyt ", b[6], "f")),x= "Time (hr)",  y="Relative density", fill= "Growth conditions")