What's the difference between facet_wrap() and facet_grid() in ggplot2?

前端 未结 4 1217
伪装坚强ぢ
伪装坚强ぢ 2020-12-13 01:31

I\'ve been reading the ggplot2 documentation for both functions. I was wondering what were the differences and what would be right situation for using each func

4条回答
  •  心在旅途
    2020-12-13 02:04

    For single variable plots you can use either facet_grid() or facet_wrap().

    facet_wrap(~variable) will return a symmetrical matrix of plots for the number of levels of variable.

    facet_grid(.~variable) will return facets equal to the levels of variable distributed horizontally.

    facet_grid(variable~.) will return facets equal to the levels of variable distributed vertically.

提交回复
热议问题