Someone_1313
Someone_1313

Reputation: 432

Avoiding different shapes in PCA using fviz_pca_ind

I performed a PCA analysis using prcomp() function. I`m trying the plot the PCA results using the function fviz_pca_ind() using the following code:

fviz_pca_ind(res_pca_nipals,
             label = "none", 
             habillage = main_metadata$Gender,
             palette = c("#1B9E77", "#D95F02"),
             axes = c(1, 2))

This works partially because it shows me the two colors for Gender and two shapes for the same column. I would like to avoid two different shapes in my PCA, for example, all circles. I used the option geom_point(shape = 1), which is not working completely because leave at least two points with different shapes (triangle and circle) I tried to avoid the option habillage, and define the colors outside the function with the:

pca.colors <- list('Gender' = c('M' = "#1B9E77", 
                                'F' = "#D95F02")

then, I use:

fviz_pca_ind(res_pca_nipals,
              label = "none", 
              #habillage = main_metadata$Gender,
              palette = pca.colors$Gender,
              axes = c(1, 2)) 

However, this resulted in no colors in my PCA and with the following warning:

Warning messages:
1: No shared levels found between `names(values)` of the manual scale and the
data's color values. 
2: No shared levels found between `names(values)` of the manual scale and the
data's fill values. 

Looks like by default ``` defines the shapes, this issue looks simple, however, I have not found a solution so far.

Any idea how to avoid this in my PCA?

Upvotes: 0

Views: 98

Answers (0)

Related Questions