从ggplot图中删除空白面

时间:2017-03-01 22:14:19

标签: r ggplot2

我有一个整洁的数据框,我试图用facet_grid绘制。我想要两排图,第一行有2个图,第二行有3个图。以下是我获得的当前情节的数据示例:

$i->usersDatabase($info)

这是数据框,它有5列,我试图在统计和统计类别上进行分析。我希望第一行图可以显示最近的defenderavg和ft_per_min,第二行的图可以得到其余部分。但是,在我的ggplot调用中,我收到了10个图,并且整个区域都有空白图。

dput(data_tidy)
structure(list(player = c("Marvin Williams", "Rudy Gay", "Rajon Rondo", 
"Spencer Hawes", "Marco Belinelli", "Kosta Koufos", "Tyler Hansbrough", 
"Darren Collison", "Omri Casspi", "DeMarcus Cousins", "Jeremy Lin", 
"Kemba Walker", "Ben McLemore", "Troy Daniels", "P.J. Hairston", 
"Willie Cauley-Stein", "Frank Kaminsky", "Marvin Williams", "Rudy Gay", 
"Rajon Rondo", "Spencer Hawes", "Marco Belinelli", "Kosta Koufos", 
"Tyler Hansbrough", "Darren Collison", "Omri Casspi", "DeMarcus Cousins", 
"Jeremy Lin", "Kemba Walker", "Ben McLemore", "Troy Daniels", 
"P.J. Hairston", "Willie Cauley-Stein", "Frank Kaminsky", "Marvin Williams", 
"Rudy Gay", "Rajon Rondo", "Spencer Hawes", "Marco Belinelli", 
"Kosta Koufos", "Tyler Hansbrough", "Darren Collison", "Omri Casspi", 
"DeMarcus Cousins", "Jeremy Lin", "Kemba Walker", "Ben McLemore", 
"Troy Daniels", "P.J. Hairston", "Willie Cauley-Stein", "Frank Kaminsky", 
"Marvin Williams", "Rudy Gay", "Rajon Rondo", "Spencer Hawes", 
"Marco Belinelli", "Kosta Koufos", "Tyler Hansbrough", "Darren Collison", 
"Omri Casspi", "DeMarcus Cousins", "Jeremy Lin", "Kemba Walker", 
"Ben McLemore", "Troy Daniels", "P.J. Hairston", "Willie Cauley-Stein", 
"Frank Kaminsky", "Marvin Williams", "Rudy Gay", "Rajon Rondo", 
"Spencer Hawes", "Marco Belinelli", "Kosta Koufos", "Tyler Hansbrough", 
"Darren Collison", "Omri Casspi", "DeMarcus Cousins", "Jeremy Lin", 
"Kemba Walker", "Ben McLemore", "Troy Daniels", "P.J. Hairston", 
"Willie Cauley-Stein", "Frank Kaminsky"), statistic = c("ft_per_min", 
"ft_per_min", "ft_per_min", "ft_per_min", "ft_per_min", "ft_per_min", 
"ft_per_min", "ft_per_min", "ft_per_min", "ft_per_min", "ft_per_min", 
"ft_per_min", "ft_per_min", "ft_per_min", "ft_per_min", "ft_per_min", 
"ft_per_min", "closestdefenderavg", "closestdefenderavg", "closestdefenderavg", 
"closestdefenderavg", "closestdefenderavg", "closestdefenderavg", 
"closestdefenderavg", "closestdefenderavg", "closestdefenderavg", 
"closestdefenderavg", "closestdefenderavg", "closestdefenderavg", 
"closestdefenderavg", "closestdefenderavg", "closestdefenderavg", 
"closestdefenderavg", "closestdefenderavg", "upr", "upr", "upr", 
"upr", "upr", "upr", "upr", "upr", "upr", "upr", "upr", "upr", 
"upr", "upr", "upr", "upr", "upr", "avgtimeWball", "avgtimeWball", 
"avgtimeWball", "avgtimeWball", "avgtimeWball", "avgtimeWball", 
"avgtimeWball", "avgtimeWball", "avgtimeWball", "avgtimeWball", 
"avgtimeWball", "avgtimeWball", "avgtimeWball", "avgtimeWball", 
"avgtimeWball", "avgtimeWball", "avgtimeWball", "holdshootscore", 
"holdshootscore", "holdshootscore", "holdshootscore", "holdshootscore", 
"holdshootscore", "holdshootscore", "holdshootscore", "holdshootscore", 
"holdshootscore", "holdshootscore", "holdshootscore", "holdshootscore", 
"holdshootscore", "holdshootscore", "holdshootscore", "holdshootscore"
), value = c(123.2, 108.3, 68.9, 135.7, 53.1, 50.7, 83.3, 44.6, 
59.1, 91.6, 71.1, 106.8, 283.5, 53.8, 103.1, 84.8, 73.8, 6.82, 
8.28, 7.64, 6.19, 8.97, 5.97, 4.57, 7.41, 10.13, 6.12, 6.39, 
6.84, 6.59, 8.07, 9.57, 5.36, 7.74, 0.39, 0.41, 0.12, 0.32, 0.58, 
0.11, 0.27, 0.27, 0.36, 0.67, 0.44, 0.36, 0.56, 0.48, 0.28, 0.42, 
0.23, 1.13, 2.04, 4.71, 1.54, 1.57, 1.8, 1.42, 3.78, 1.28, 2.29, 
3.42, 6.22, 1.81, 1.37, 1.66, 0.88, 1.49, 1.99, 3.7, 6.01, 2.52, 
0.92, 3.79, 0.96, 6.18, 2.46, 5.06, 7.6, 15.25, 3.25, 2.05, 5.48, 
1.14, 3.98), this_player = structure(c(2L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("0", 
"1"), class = "factor"), statcategory = c("Lazy", "Lazy", "Lazy", 
"Lazy", "Lazy", "Lazy", "Lazy", "Lazy", "Lazy", "Lazy", "Lazy", 
"Lazy", "Lazy", "Lazy", "Lazy", "Lazy", "Lazy", "Lazy", "Lazy", 
"Lazy", "Lazy", "Lazy", "Lazy", "Lazy", "Lazy", "Lazy", "Lazy", 
"Lazy", "Lazy", "Lazy", "Lazy", "Lazy", "Lazy", "Lazy", "Selfish", 
"Selfish", "Selfish", "Selfish", "Selfish", "Selfish", "Selfish", 
"Selfish", "Selfish", "Selfish", "Selfish", "Selfish", "Selfish", 
"Selfish", "Selfish", "Selfish", "Selfish", "Selfish", "Selfish", 
"Selfish", "Selfish", "Selfish", "Selfish", "Selfish", "Selfish", 
"Selfish", "Selfish", "Selfish", "Selfish", "Selfish", "Selfish", 
"Selfish", "Selfish", "Selfish", "Selfish", "Selfish", "Selfish", 
"Selfish", "Selfish", "Selfish", "Selfish", "Selfish", "Selfish", 
"Selfish", "Selfish", "Selfish", "Selfish", "Selfish", "Selfish", 
"Selfish", "Selfish")), .Names = c("player", "statistic", "value", 
"this_player", "statcategory"), row.names = c(NA, -85L), class = "data.frame")

我获得了以下情节:

enter image description here

我认为我需要以不同的方式构造数据帧,而不是将额外的参数传递给ggplot()调用,但我不确定。我希望将我的数据转换为上面的data_tidy格式是可行的,但显然它没有。

任何帮助一如既往的赞赏!

0 个答案:

没有答案