Hi is there a way to plot only the loadings in a biplot (with the nice arrows), and to skip the scores? thanks christoph
Christoph Lehmann wrote:> Hi > > is there a way to plot only the loadings in a biplot (with the nice > arrows), and to skip the scores? > > thanks > christoph >Hi Christoph, Three options I can think of: 1) Hack the source for biplot.princomp and biplot.default (which does the plotting) by commenting out the lines that plot the scores or altering the code to plot only the scores. You want to plot just y[,1] against y[,2] and ignore the x[,1] and x[,2] bits in biplot.default. 2) Write your own function based on biplot.default and biplot.princomp 3) If you don't like hacking/coding then see package vegan and the function scores, which has a method for class princomp, which can extract the loadings and the scores (in princomp terms, vegan calls them something else). Function ordiplot (also in vegan) provides direct plotting of various ordination results including objects from princomp. All the best, Gav -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [T] +44 (0)20 7679 5522 ENSIS Research Fellow [F] +44 (0)20 7679 7565 ENSIS Ltd. & ECRC [E] gavin.simpson at ucl.ac.uk UCL Department of Geography [W] http://www.ucl.ac.uk/~ucfagls/cv/ 26 Bedford Way [W] http://www.ucl.ac.uk/~ucfagls/ London. WC1H 0AP. %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Not and have a biplot, as defined by the person who named them. Have you bothered to read the references on the help page? Please read them (more carefully if necessary). On Thu, 30 Sep 2004, Christoph Lehmann wrote:> is there a way to plot only the loadings in a biplot (with the nice > arrows), and to skip the scores?-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
On Thu, 2004-09-30 at 10:33, Christoph Lehmann wrote:> Hi > > is there a way to plot only the loadings in a biplot (with the nice > arrows), and to skip the scores? >Christoph, I may have overlooked some email messages, but it seems to me that you haven't yet got an answer to your practical question. From the practical point of view, we may skip the point that you rather ask for a "monoplot" than "biplot" if you have only one set of points. Further, I may forget my surprise when I see that somebody really thinks that these arrows are "nice". OK, they may be nice if you have only a couple of them, but anybody plotting 30 or more arrows normally asks how to get rid off this mess. Of course you can plot arrows in your "monoplot", since you have got access to everything in R and you can do anything with R (but coffee comes somewhat bland, so I recommend something else for the task cooking coffee). Here is an example: # Run PCA data(USArrests) sol <- princomp(USArrests, cor=T) # Extract loadings X <- sol$loadings # Plot the frame plot(X, asp=1, type="n") abline(v=0, lty=3) abline(h=0, lty=3) # Plot arrows: see ?arrows for the syntax arrows(0, 0, X[,1], X[,2], len=0.1, col="red") # Label the arrows text(1.1*X, rownames(X), col="red", xpd=T) Cheers, jari okanen -- Jari Oksanen <jarioksa at sun3.oulu.fi>