使用 ggplot 在同一个图上的三组不同的点

Three different sets of points on the same plot using ggplot

我通过多元正态分布创建了三组点:

library('MASS')
library('ggplot2')
library('reshape2')
library("ClusterR")
library("cluster")
mu1<-c(1,1)
mu2<-c(1,-9)
mu3<-c(-7,-2)
mu1
mu2
mu3
sigma1<-matrix(c(1,1,1,2), nrow=2, ncol=2, byrow = TRUE)
sigma2<-matrix(c(1,-1,-1,2), nrow=2, ncol=2, byrow = TRUE)
sigma3<-matrix(c(2,0.5,0.5,0.3), nrow=2, ncol=2, byrow = TRUE)
sigma1
sigma2
sigma3
simulation1<-mvrnorm(100,mu1,sigma1)
simulation1
simulation2<-mvrnorm(100,mu2,sigma2)
simulation2
simulation3<-mvrnorm(100,mu3,sigma3)
simulation3
X<-rbind(simulation1,simulation2,simulation3)
colnames(X)<-c("x","y")
X<-data.frame(X)
X

我需要用不同的颜色在一个图上表示这些集合。在这里,我将附上图片应该是什么样子: Graphic 有人可以帮助我,我该怎么做?我知道图像上的图形是由 ggplot 创建的,但我不知道如何将它用于我的集合。

只需向数据框添加一些指标 X 即可生成该图

X$group <- rep(c("1","2","3"), each = 100)
X %>%
  ggplot(aes(x,y, group = group, color = group)) +
  geom_point() + xlab("aaaa") + ylab("bbbb")