简体   繁体   中英

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:

Error in FUN(X[[i]], ...) : object 'x' not found

There's no problem plotting graf, but I can't understand why R tells me there's is an error with grafica2

PD: Ej4 is a dataframe with numerical variables, with the exactly same size as 'variable'

还有一种方法:

ggplot() + geom_point(data = Ej4, aes(x1,y1)) + geom_point(data = variable, aes(y,y2))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM