ggplot2“geom_path需要以下缺失的美学”

时间:2014-03-10 21:26:27

标签: r plot ggplot2

我一直在忙着建立一个拍摄图表数据的散点图,并且想要在它背后画一个篮球场。我已经在其他stackoverflow问题上看到了这一点,但即使在复制代码时我也无法使用它。

我可以单独运行我的散点图,现在它的设置方式是完美的。如果我添加一个,我可以单独运行所有geom_path()语句 "ggplot(data=data.frame(x=1,y=1),aes(x,y))+ 到geom_path语句的顶部,但是当我尝试将它们放在一起时,我收到错误

我在所有语句中都拥有所有inherit.aes = FALSE的原因是因为我确信在此之前我遇到的“对象”x.coord“未找到”错误是由于geom_path语句继承自ggplot语句。

chart.player <- ggplot(player5, aes(x =x.coord,y =y.coord , col = pts_att, size = log)) +
  geom_point() + scale_colour_gradient("Points/Attempt", low = "green", high="red") + coord_fixed() +

  ###outside box:
  geom_path(data=outside_box,inherit.aes=FALSE)+
  ###solid FT semicircle above FT line:
  geom_path(data=ft_semi_above,aes(x=x,y=y),inherit.aes=FALSE)+
  ###dashed FT semicircle below FT line:
  geom_path(data=ft_semi_below,aes(x=x,y=y),linetype='dashed',inherit.aes=FALSE)+
  ###key:
  geom_path(data=key,inherit.aes=FALSE)+
  ###box inside the key:
  geom_path(data=box_key,inherit.aes=FALSE)+
  ###restricted area semicircle:
  geom_path(data=ra_semi,aes(x=x,y=y),inherit.aes=FALSE)+
  ###halfcourt semicircle:
  geom_path(data=half_semi,aes(x=x,y=y),inherit.aes=FALSE)+
  ###rim:
  geom_path(data=rim,aes(x=x,y=y),inherit.aes=FALSE)+
  ###backboard:
  geom_path(data=backboard,lineend='butt',inherit.aes=FALSE)+
  ###three-point line:
  geom_path(data=threept,aes(x=x,y=y),inherit.aes=FALSE)

plot(chart.player)
Error: geom_path requires the following missing aesthetics: x, y

任何帮助表示赞赏!感谢

0 个答案:

没有答案