Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Labeling points in a biplot

Tags:

plot

r

pca

I have performed a PCA and drawn a biplot in R.

pca1= princomp (~ data$X250 + data$X500 + data$shear, scores=TRUE, cor=TRUE, rownames=data[,1])
biplot(pca1, xlab="PC 1", ylab="PC 2", pch=20)

Currently the labels on the biplot are the row numbers, but I would like the point labels to be the plot names of my data. My data has 81 rows.

I have tried:

text (pca1[1:81], pca1[1:81], labels = row.names(data))
text (1:81, 1:81, labels = row.names(data))
text (pca1$comp.1[1:81], pca1$comp.2[1:81], labels = row.names(data))
like image 971
user3032264 Avatar asked Nov 25 '13 13:11

user3032264


People also ask

What does the biplot show?

The biplot is a very popular way for visualization of results from PCA, as it combines both the principal component scores and the loading vectors in a single biplot display. The plot shows the observations as points in the plane formed by two principal components (synthetic variables).

What are the axes of a biplot?

The axes in the biplot represent the columns of coefs , and the vectors in the biplot represent the rows of coefs (the observed variables). biplot( coefs , Name,Value ) specifies additional options using one or more name-value pair arguments.

What does a PCA biplot tell you?

In summary: A PCA biplot shows both PC scores of samples (dots) and loadings of variables (vectors). The further away these vectors are from a PC origin, the more influence they have on that PC.


2 Answers

Try giving

rownames(data)<-data[,1] 

before using princomp

like image 151
George Dontas Avatar answered Sep 30 '22 13:09

George Dontas


If you don't want to set the rownames on your original data set ("df", below), you can also do it by passing the xlabs argument to biplot:

p<-princomp(df) 
biplot(p,xlabs=df[,1])
like image 24
John Avatar answered Sep 30 '22 12:09

John