overlapping texts (plot.PCA in FactoMineR)
1
0
Entering edit mode
8.8 years ago
mbk0asis ▴ 700

Hi, all!

I was trying to draw a PCA plot using FactoMineR (a R package). When I ran it, texts on the plots were overlapped with unknown numbers.

Here's the R code

library(FactoMineR)
pca<-PCA(dta.cor, scale.unit=T)
plot.PCA(pca,cex=1)

and the result plot

enter image description here

As you can see numbers in pink are covering sample names.

I couldn't figure it out.

Please, someone help me!!

Thank you!!!

R factominer • 12k views
ADD COMMENT
0
Entering edit mode

You can explore the options by looking at the help. ?plot.PCA It looks like it has label= and autoLab= options which may be useful to turn off the unwanted labels. Try to troubleshoot it yourself first, which is the best way to learn.

ADD REPLY
0
Entering edit mode

Adding to other suggestions check geom_text_repel form ggrepel Check its vignette here

ADD REPLY
0
Entering edit mode

Thank you, all! You guys been great help!

ADD REPLY
3
Entering edit mode
8.8 years ago

You can use prcomp for PCA calculations and then plot it using ggplot and add labels using ggrepel.

ggrepel provides geoms for ggplot2 to repel overlapping text labels. It works both for geom_text and geom_label.

enter image description here

Figure is taken from this blog post.

ADD COMMENT
0
Entering edit mode

Neat! Didn't know this ggplot feature. Thanks!

ADD REPLY
0
Entering edit mode

The labels are from ggrepel, a package by Kamil. ggrepel: repel overlapping text labels in ggplot2

ADD REPLY

Login before adding your answer.

Traffic: 1636 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6