rggplot2plotdimensionality-reductionarchetypes

Change color of groups in xyplot - archetypal analysis


I have an xyplot that plots archetypes of a umap plot like below. Every single one of these points belongs to a timepoint stored in a list. How do I change the color of these points to reflect time accordingly?

The head(umapped$layout) is

 [,1]      [,2]
1 -0.9905974  5.016414
2 -2.0759074  2.087989
3  0.6921594 -1.780826
4 -2.9713005  8.018761
5 -3.7351895  7.015174
6 -3.6934716  5.780606

and I found the archetypes through

archetypes(umapped$layout, 3)->a

This is how I am plotting:

xyplot(a, umapped$layout, chull = chull(umapped$layout))

This is the head of the list containing the time info for every data point.

head(my.time)

[1] "3" "3" "3" "3" "3" "7"

Is there a way I can convert this plot into a ggplot?


Solution

  • To include colors all we need to do is add my.time as an extra argument in the xyplot so

    xyplot(a, umapped$layout, chull = chull(umapped$layout),my.time)
    

    fixes the issue.