Home > other >  Three different sets of points on the same plot using ggplot
Three different sets of points on the same plot using ggplot

Time:10-01

I have created three sets of points by multivariate normal distibution:

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

I need to represent these sets on one plot with different colours. Here I will attach image how it should be look like: enter image description here

  • Related