Highlighting individual axis labels in bold using ggplot2

后端 未结 3 2028
无人共我
无人共我 2020-12-31 10:58

I want to highlight individual axis labels in bold. I am aware of this answer by @MrFlick but I can\'t figure out how to do this a) for more than one item,

3条回答
  •  北海茫月
    2020-12-31 11:46

    I'm not sure if you can map label characteristics by name, but it's definitely possible to do it by position with a call to theme:

    ggplot(xx, aes(x=CLONE, y=VALUE, fill=YEAR)) + 
      geom_bar(stat="identity", position="dodge") +
      facet_wrap(~TREAT) +
      theme(axis.text.x = element_text(face = c('bold', 'bold', 'plain', 'plain', 'bold')))
    

    Note that the listed font faces for axis.text.x are the same length as the labels of your x-axis (five elements). This produces:

提交回复
热议问题