How to use ggplot to plot T-SNE clustering

前端 未结 1 1874
梦毁少年i
梦毁少年i 2021-01-14 08:09

Here is the t-SNE code using IRIS data:

library(Rtsne)
iris_unique <- unique(iris) # Remove duplicates
iris_matrix <- as.matrix(iris_unique[,1:4])
set.         


        
1条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-14 08:39

    I think the easiest/cleanest ggplot way would be to store all the info you need in a data.frame and then plot it. From your code pasted above, this should work:

    library(ggplot2)
    tsne_plot <- data.frame(x = tsne_out$Y[,1], y = tsne_out$Y[,2], col = iris_unique$Species)
    ggplot(tsne_plot) + geom_point(aes(x=x, y=y, color=col))
    

    My plot using the regular plot function is:

    plot(tsne_out$Y,col=iris_unique$Species)
    

    0 讨论(0)
提交回复
热议问题