Hi,

I am making PCA plot in R using `PCAtools` for different group of individuals. The are 65 groups in the sample metadata. At the moment, for smaller groups I simply specify color for each of them in `colkey` (for instance, `"Group 1" = "#004181"`, `"Group 2" = "#0077BA"`, ................, etc). I am not sure how to add colors for more number of groups and manually specifying them would be tedious. Is there a better way to do this?

    Plot_Type = "PCA2D"
    pdf(paste0(Plot_Type,"_PC1_vs_PC2.pdf"),height = 7,width = 10)
    biplot(p,
           x = 'PC1', y = 'PC2',
           lab = NULL,
           colby = 'Group', colkey = c('Group 1' = '#004181', 'Group 2' = '#0077BA', 'Group 3' = '#4E564D', 'Group 4' = '#6BA3D7', 'Group 5' = '#8B63FF'),
           legendPosition = 'right', legendLabSize = 13, legendIconSize = 3.0,
           subtitle = 'PC1 vs. PC2')
    dev.off()

I will appreciate any help. Thank you!

Best Regards,

Toufiq
Using *rainbow* to create **n** colours, then *setNames* to create a named vector:

    # using 5 as a test, change it to as needed, 65?
    n = 5
    
    myCols <- setNames(rainbow(n), paste("Group", 1:n))
    
    myCols
    #   Group 1   Group 2   Group 3   Group 4   Group 5 
    # "#FF0000" "#CCFF00" "#00FF66" "#0066FF" "#CC00FF" 
    
    # then use within your code:
    colby = "Group", colkey = myCols,


**Note:** 
- No one can tell a difference between 65 colours.
- There are [other packages/functions](https://stackoverflow.com/q/15282580/680068) to create pallets with **n** number of colours, instead of *rainbow*.