[R] centre two graphs on one plot

chris20 bop07crb at sheffield.ac.uk
Wed Jun 29 21:37:04 CEST 2011


Hi,

I am trying to put together a biplot using symbols and different colours
instead of text as points.

Someone has previously suggested using this code:

PC <- prcomp (iris[,1:4])
lambda <- PC$sdev * sqrt(nrow(PC$x))
plot (t(t(PC$x)/lambda),pch=16,col=as.numeric(iris[,5]))
par (new=T)
Rot <- t(t(PC$rotation)*lambda)
XLIM <- c(-max(abs(Rot[,1])),max(abs(Rot[,1])))
XLIM <- XLIM+(XLIM*0.7)
plot(Rot,col=4,axes=FALSE,xlim=XLIM,ylim=XLIM,pch="")
arrows
(rep(0,nrow(PC$rotation)),rep(0,nrow(PC$rotation)),Rot[,1],Rot[,2],col=4)
text (Rot[,1:2],rownames(Rot),col=6)
axis (3)
axis (4)

But the origin of the arrows does not line up with the origin of the points. 
Can anyone suggest how you would get the two graphs to line up?  I think you
have to set a ratio between the two sets of axes so that the origin is in
the centre but I don't know how to do it.

Thanks
Chris

--
View this message in context: http://r.789695.n4.nabble.com/centre-two-graphs-on-one-plot-tp3633788p3633788.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list