How to create a faceted line-graph using ggplot?

淺唱寂寞╮ 提交于 2019-12-03 22:19:30

Try this:

ggplot(data=alldf.m, aes(x=variable, y = value, colour = ID, group = ID)) + 
  geom_line() + facet_wrap(~fn)

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)

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())

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!