title: How to change the order and labels of facets at the same time?
body: <p>I'd like to change the order and labels of facets in a ggplot2 figure. I could change the order or labels separately, but could not change them at the same time. I followed <a href="https://stackoverflow.com/a/66578130/3211736">this line</a> to change the order and <a href="https://www.datanovia.com/en/blog/how-to-change-ggplot-facet-labels/#:%7E:text=Facet%20labels%20can%20be%20modified,labeller%20function%20label_both%20is%20used." rel="nofollow noreferrer">this link</a> for labels. Any help? Thanks.</p>
  <pre><code>library(ggplot2)
  
  df &lt;- data.frame(x = seq(1, 8), y = seq(2, 9), cat = rep(c('a', 'b'), 4))
  
  label &lt;- c('label_1', 'label_2')
  names(label) &lt;- c('a', 'b')
  
  df %&gt;% 
    ggplot() +
    geom_line(aes(x = x, y = y)) +
    facet_grid(fct_relevel(cat, c('b', 'a')) ~., # change the order of facet
               labeller = labeller(cat = label)) # change the label of facet, failed
  </code></pre>