我正在尝试用facet学习ggplot。这里的代码适用于Rstudio
p <- ggplot(mtcars, aes(mpg, wt)) + geom_point()
# With one variable
p + facet_grid(. ~ cyl)
然而,在我添加ncol = 2后,它显示ncol的错误:
p + facet_grid( ~ cyl,ncol=2)
Error in facet_grid(~cyl, ncol = 2) : unused argument (ncol = 2)
答案 0 :(得分:6)
#use facet_wrap
p + facet_wrap( ~ cyl, ncol = 2)