Change facet label text and background colour

前端 未结 2 1497
时光说笑
时光说笑 2020-12-29 18:35

How can I change the grey facet labels (A and B) into say red background with white text?

A = data.table(x = 1:4, y = 1:4, z = c(\'A\',\'A\',\'B\',\'B\'))
gg         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-29 19:21

    You can do:

    ggplot(A) +
      geom_point(aes(x = x, y = y)) +
      facet_wrap(~z) +
      theme_bw()+
      theme(strip.background =element_rect(fill="red"))+
      theme(strip.text = element_text(colour = 'white'))
    

提交回复
热议问题