[英]Aesthetics must be either length 1 or the same as the data
我想在ggplot中添加一些点,但是当我添加一些额外的点时,它会带来错误并说“美学必须为1或与数据相同”,这是怎么回事,以及如何解决?
ggplot(as.data.frame(AAPLtrans), mapping = aes(x = AAPLtrans$Date, y = AAPLtrans$Adj.Close, group=1)) +
geom_point(size=I(0.2)) + aes(colour = factor(DBOTfunc(num))) +
geom_line() +
geom_point(aes(x=AAPL[P[num,][5],]$Date, y=AAPL[P[num,][5],]$Adj.Close), colour="black", shape=1, size=3) +
geom_point(aes(x=AAPL[P[num,][4],]$Date, y=AAPL[P[num,][4],]$Adj.Close), colour="black", shape=1, size=3) +
geom_point(aes(x=AAPL[P[num,][3],]$Date, y=AAPL[P[num,][3],]$Adj.Close), colour="black", shape=1, size=3) +
geom_point(aes(x=AAPL[P[num,][2],]$Date, y=AAPL[P[num,][2],]$Adj.Close), colour="black", shape=1, size=3)
一种可能是您在aes映射中无意中拼写了变量名之一。 可能是大小写不同吗? 这将造成长度不匹配,不同之处是列号拼写错误。
您有一个没有aes包装器的geom_line(),可以吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.