How to change facet labels?

后端 未结 20 1863
既然无缘
既然无缘 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:35

    The EASIEST way to change WITHOUT modifying the underlying data is:

    1. Create an object using the as_labeller function adding the back tick mark for each of the default values:

      hum.names <- as_labeller(c(50 = "RH% 50", 60 = "RH% 60",70 = "RH% 70", 80 = "RH% 80",90 = "RH% 90", 100 = "RH% 100")) #Necesarry to put RH% into the facet labels

    2. We add into the GGplot:

      ggplot(dataframe, aes(x=Temperature.C,y=fit))+geom_line()+ facet_wrap(~Humidity.RH., nrow=2,labeller=hum.names)

提交回复
热议问题