Hello mixOmics team
I have tried a sPLS-DA in my analysis and when doing plotInd area prediction background I struggled to manually change legend labels. For example, in ggplot2 I can set scale_fill_manual and change color and labels. Is there a workaround to get it done?
You can adjust the legend title and labels using the scale_colour_discrete()
function from ggplot
. Note, depending on your scenario, you may need to use the scale_fill_discrete()
library(mixOmics)
data("breast.TCGA")
X <- breast.TCGA$data.train$mirna
Y <- breast.TCGA$data.train$subtype
model <- splsda(X, Y)
bg <- background.predict(model, comp.predicted = 2)
fig <- plotIndiv(model, background = bg, legend=T)$graph
fig <- fig + scale_colour_discrete(name = "Class", labels=c('label1', 'label2', 'label3'))
#> Scale for 'colour' is already present. Adding another scale for 'colour',
#> which will replace the existing scale.
fig
Created on 2022-11-07 with reprex v2.0.2
Thank you Max. It worked for me.