R ggplot2";geom“U路径需要以下缺失的美学”;

R ggplot2";geom“U路径需要以下缺失的美学”;,r,plot,ggplot2,R,Plot,Ggplot2,我一直在忙着建立一个投篮图数据的散点图,并想在它后面画一个篮球场。我在其他stackoverflow问题上也看到过这种情况,但即使在复制代码时,我也无法让我的代码正常工作 我可以单独运行我的散点图,很好,现在它的设置方式非常完美。我可以单独运行所有geom_path()语句,如果添加 “ggplot(data=data.frame(x=1,y=1),aes(x,y))+ 到geom_path语句的顶部,但当我尝试将它们放在一起时,我得到了一个错误 我在所有语句中都有inherit.aes=FAL

我一直在忙着建立一个投篮图数据的散点图,并想在它后面画一个篮球场。我在其他stackoverflow问题上也看到过这种情况,但即使在复制代码时,我也无法让我的代码正常工作

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

我在所有语句中都有inherit.aes=FALSE的原因是我确信在此之前出现的“object”x.coord“not found”错误是由于从ggplot语句继承的geom_path语句造成的

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

chart.player您可能想将aes值添加到geom_path(),但没有aes值。这实际上效果很好。现在绘图工作正常!但是,我注意到,现在我的“大小”图例稍微变差,显示的是不同厚度的黑条,而不是圆圈大小(表示频率).希望我能弄明白这一点!谢谢!