How to specify columns in facet_grid OR how to change labels in facet_wrap

前端 未结 4 659
难免孤独
难免孤独 2020-12-02 15:22

I have a large number of data series that I want to plot using small multiples. A combination of ggplot2 and facet_wrap does what I want, typically resulting a

4条回答
  •  悲哀的现实
    2020-12-02 16:09

    I don't quite understand. You've already written a function that converts your short labels to long, descriptive labels. What is wrong with simply adding a new column and using facet_wrap on that column instead?

    mydf <- melt(mydf, id = c('date'))
    mydf$variableLab <- mf_labeller('variable',mydf$variable)
    
    p1 <- ggplot(mydf, aes(y = value, x = date, group = variable)) +
        geom_line() +
        facet_wrap( ~ variableLab, ncol = 2)
    print (p1)
    

提交回复
热议问题