我需要为数据帧显示213 x 4的图形网格。 当我在ggplot2中使用以下命令时,该图是一个长图形的长线性显示
ggplot(data=r,aes(x=wicketPlayerOut,y=runs,fill=wicketPlayerOut)) +
facet_grid(. ~ bowler,scales = "free_x", space = "free_x") +
geom_bar(stat="identity") +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
我尝试使用facet_wrap,但收到错误
" layout_base中的错误(数据,变量,drop = drop): 至少一个图层必须包含用于刻面的所有变量"
我用于facet_wrap的命令如下
ggplot(data=r,aes(x=wicketPlayerOut,y=runs,fill=wicketPlayerOut)) +
facet_wrap(. ~ bowler,scales = "fixed",ncol=4,drop=TRUE)+
geom_bar(stat="identity") +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
答案 0 :(得分:1)
已更改为以下
ggplot(data=r,aes(x=wicketPlayerOut,y=runs,fill=wicketPlayerOut)) +
facet_wrap( ~ bowler,scales = "fixed",ncol=4,drop=TRUE)+
geom_bar(stat="identity") +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
,显示现在为nrow x ncol