[英]Error plotting in a second series in ggplot2
I want to plot a scatter plot with two different series:我想用两个不同的系列绘制散点图:
Ej4 = read.xlsx("C:\\Users\\Ulia\\Downloads\\Parte 5.xlsx", sheet = 4)
fix(Ej4)
graf = ggplot(Ej4, aes(x1,x1)) + geom_point(alpha = 0.8)
graf
variable = data.frame(y = c(6,9,6,17,12), y2= c(6,9,6,17,12))
variable
grafica2 = graf + geom_point() +
geom_point(data = variable, colour ="blue")
grafica2
But R shows this error:但 R 显示此错误:
Error in FUN(X[[i]], ...) : object 'x' not found
FUN(X[[i]], ...) 中的错误:找不到对象“x”
There's no problem plotting graf, but I can't understand why R tells me there's is an error with grafica2绘制 graf 没有问题,但我不明白为什么 R 告诉我 grafica2 有错误
PD: Ej4 is a dataframe with numerical variables, with the exactly same size as 'variable' PD:Ej4 是一个带有数值变量的数据框,大小与“变量”完全相同
还有一种方法:
ggplot() + geom_point(data = Ej4, aes(x1,y1)) + geom_point(data = variable, aes(y,y2))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.