Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a 100 2-dim points, which form a 100 by 2 matrix X, stored in a text file "data"

I have a 100-dim vector Y, which form the class labels (numerical from 1 to 3) of the 100 points, and is stored in a text file "labels".

In R, I was wondering how you would plot the 2-dim points in X, s.t. each point is represented by its class label instead of a dot and represented in a color of its class label (the color is same for points of the same class label, but different for points of different class labels)?

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
243 views
Welcome To Ask or Share your Answers For Others

1 Answer

Do you want to do something like this?

x1 <- runif(100)
x2 <- runif(100)
y  <- sample.int(3 , 100 , replace = T)

df <- data.frame( x1,x2,y)
ggplot( df )+
geom_text( aes( x1 , x2 , label = y , colour = factor(y)))

plot


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...