Question: overlapping texts (plot.PCA in FactoMineR)
0
gravatar for mbk0asis
4.2 years ago by
mbk0asis530
Korea, Republic Of
mbk0asis530 wrote:

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!!!

factominer R • 4.0k views
ADD COMMENTlink modified 4.2 years ago • written 4.2 years ago by mbk0asis530

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 REPLYlink modified 4.2 years ago • written 4.2 years ago by geek_y11k

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

ADD REPLYlink written 4.2 years ago by venu6.6k

Thank you, all! You guys been great help!

ADD REPLYlink written 4.2 years ago by mbk0asis530
3
gravatar for Sukhdeep Singh
4.2 years ago by
Netherlands
Sukhdeep Singh10k wrote:

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 COMMENTlink modified 4.2 years ago • written 4.2 years ago by Sukhdeep Singh10k

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

ADD REPLYlink written 4.2 years ago by Manu Prestat4.0k

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

ADD REPLYlink written 4.2 years ago by Sukhdeep Singh10k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1773 users visited in the last hour