How to create a faceted line-graph using ggplot?

后端 未结 2 574
暖寄归人
暖寄归人 2021-02-18 13:37

I have a data frame created with this code:

require(reshape2)
foo <- data.frame( abs( cbind(rnorm(3),rnorm(3, mean=.8),rnorm(3, mean=.9),rnorm(3, mean=1))))
q         


        
2条回答
  •  被撕碎了的回忆
    2021-02-18 14:30

    Even it is a ggplot2 is required by the OP , but I think this example is suitable for lattice also:

    library(lattice)
    xyplot(data=alldf.m, value~variable|fn, type ='b', groups = ID, auto.key = T)
    

    enter image description here

    and using latticeExtra we can get something colse to ggplot2 solution:

     p <-  xyplot(data=alldf.m, value~variable|fn, type ='b', groups = ID, auto.key = T)
     update(p , par.settings = ggplot2like())
    

    enter image description here

提交回复
热议问题