标签: r ggplot2 facet-wrap facet-grid
我想知道如何对以下ggplot(在油漆中编辑)绘制的图表进行分组:Plot
ggplot
看起来facet_wrap()和facet_grid()函数不能用于排列列和子列。
facet_wrap()
facet_grid()
我可以使用任何R包吗?
由于
答案 0 :(得分:0)
您可以将用于列和子列的因子相乘。
library(ggplot2) ggplot(mtcars, aes(disp, mpg)) + geom_point() + facet_wrap(~ cyl * gear, labeller = label_both)
这里的labeller label_both也很有用,因为它会在facet标题中的值之前添加变量名称。
labeller
label_both