Re: [R] superimpose histogram on biplot

From: Stéphane Dray <dray_at_biomserv.univ-lyon1.fr>
Date: Tue, 01 Apr 2008 18:37:15 +0200

Hi Jennie,
if you have questions about ade4, you can use the adelist http://listes.univ-lyon1.fr/wws/info/adelist

ade4 has the add.scatter.eig function which is exactly what you need. Try

add.scatter.eig(nipmat$eig, xax=1, yax=2)

Cheers,

Jennie Lavine wrote:
> Hi all,
>
> I've been trying to figure out how to superimpose a histogram on a
> biplot that shows the relative contribution of each axis. I have
> been using the NIPALS function (http://biomserv.univ-lyon1.fr/~dray/
> files/softwares/nipals.R) to run principal component analyses. Here
> is a toy example.
>
> source("http://biomserv.univ-lyon1.fr/~dray/files/softwares/nipals.R")
> mat=matrix(runif(100,0,1), ncol=10, nrow=10)
> nipmat=nipals(mat, nf=9)
> scatter(nipmat)
>
> In the plot generated by the above "scatter" command, there is a
> histogram in the upper left corner. I want to know how to
> superimpose that histogram on a similar plot, such as the following:
>
> groups = as.factor(c(rep(1,2), rep(2,4), rep(3,4)))
> s.arrow(dfxy=nipmat$co[,1:2]*8, sub="Day 10", possub="bottomleft",
> csub=3)
> s.class(dfxy=nipmat$li[,1:2], fac=groups, cellipse=2, axesell=F,
> cstar=0 , col=c(2:3), add.plot=T)
>
> I can create the histogram using:
>
> plot(nipmat$eig/sum(nipmat$eig), type='h')
>
> but I don't know how to superimpose it on the above graph.
>
> Thanks for any help!
>
> Best,
> Jennie
>
>
> Jennie Lavine
> PhD Candidate
> Center for Infectious Disease Dynamics
> Penn State University
> 505 ASI Building
> (814)863-1815
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
>

-- 
Stéphane DRAY (dray_at_biomserv.univ-lyon1.fr )
Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - Lyon I
43, Bd du 11 Novembre 1918, 69622 Villeurbanne Cedex, France
Tel: 33 4 72 43 27 57       Fax: 33 4 72 43 13 88
http://biomserv.univ-lyon1.fr/~dray/

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 01 Apr 2008 - 16:43:22 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 01 Apr 2008 - 17:30:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive