Search code examples
rggplot2facet-wrap

How to remove the comma in facet labels when ".multi_line = FALSE"


ggplot(mpg, aes(displ, hwy)) +
      geom_point() +
      facet_wrap(c("cyl", "drv"), labeller = labeller(.multi_line = FALSE))

I would like to replace the comma with space in labels.

Code output


Solution

  • mpg$label <- paste(mpg$cyl, mpg$drv)
    
    ggplot(mpg, aes(displ, hwy)) +
          geom_point() +
          facet_wrap(~label)
    

    Final plots