How to change facet labels?

后端 未结 20 1966
既然无缘
既然无缘 2020-11-22 14:50

I have used the following ggplot command:

ggplot(survey, aes(x = age)) + stat_bin(aes(n = nrow(h3), y = ..count.. / n), binwidth = 10)
  + scale         


        
20条回答
  •  我在风中等你
    2020-11-22 15:25

    Simple solution (from here):

    p <- ggplot(mtcars, aes(disp, drat)) + geom_point()
    # Example (old labels)
    p + facet_wrap(~am)
    
    
    to_string <- as_labeller(c(`0` = "Zero", `1` = "One"))
    # Example (New labels)
    p + facet_wrap(~am, labeller = to_string)
    

提交回复
热议问题