Search code examples
rcorrespondence-analysisfactominerfactoextra

Change colour of supplementary column using factoextra in R


I am trying to change the colour used for the supplementary column in a correspondence analysis using fviz_ca_col() from the package factoextra, but I do not seem to get any response when changing the colour from the default col.col.sup = "darkred". Reproducible example:

library(FactoMineR)
library(factoextra)

# Load example data
data("housetasks")

# Perform correspondence analysis
resca <- CA(housetasks, 
                 col.sup = which(names(housetasks) == "Alternating"),  
                 graph = FALSE)

# Call to plot
fviz_ca_col(resca, col.col.sup = "black")

The resulting plot has the supplementary column "Alternating" in the default dark red colour:

enter image description here


Solution

  • There's a bug in the source code:

    fviz (X, element = "col", axes = axes, geom = geom.col,
            color = col.col, alpha = alpha.col,
            pointshape = shape.col, select = select.col, 
            map = map, repel = repel, 
            colcol.sup = col.col.sup, shape.sup = shape.col, ...)
    

    The input parameter should be col.col.sup = instead of colcol.sup =

    One way is to call fviz:

    fviz(resca,element="col",col.col.sup="black")
    

    enter image description here