将两个散点图合二为一

combine two scatterplots in one

我是 R.I 的新手,需要组合两个散点图 plot(x1, y1) plot(x2, y2) 并希望将它们绘制在同一个图中。我该怎么做?我尝试了以下代码。

df
    x1  y1  x2  y2
1  3.6 6.7 5.8 8.9
2 12.7 9.2 8.6 9.0
3  5.8 8.9 7.9 8.7
4   NA  NA 9.0 4.5
5   NA  NA 6.0 9.0
 x1= df$x1
 x2=df$x2
 y1=df$y1
 y2=df$y2
 d1 <- data.frame(x = x1, y = y1)
 d2 <- data.frame(x = x2, y = y2)
 library(reshape2)
 d3 <- rbind(melt(d1, id.vars = "x1") , melt(d2, id.vars = "x1"))
Error: id variables not found in data: x1
 library(ggplot2)
 ggplot(d3, aes(x1, y = value, colour = variable)) + 
+     geom_point() + labs(x = "x", y = "y")+ xlim(0,100) + ylim(0,100) +
+     scale_colour_manual(values = c("red", "blue"), labels = c("d1", "d2"))
Error in ggplot(d3, aes(x1, y = value, colour = variable)) : 
  object 'd3' not found

您的帮助将不胜感激!

x1 <- 1:5
y1 <- 11:15
x2 <- 5:1
y2 <- 11:15
df <- data.frame(x1, y1, x2, y2)

ggplot(df) + geom_point(aes(x = x1, y = y1)) + geom_point(aes(x = x2, y = y2)

Here's the basic plot that is generated