[R] Biplots

Thomas W Blackwell tblackw at umich.edu
Mon Mar 10 23:54:55 CET 2003



On Mon, 10 Mar 2003, Damon Wischik wrote:

> I want to plot biplots. I have seen the function biplot, but there are
> some extra features I would like, that I do not know how to achieve.
>
> 1. My observations, and my variables, fall into groups. Is there a way to,
> say, plot the observations in several different colours, according to
> which group the observation falls into? Similarly with the variables? I am
> used to the lattice idiom, in which one specifies groups= and
> panel.groups=, but biplot is not (if I understand correctly) a lattice
> function, and I don't know how to express what I want with the biplot
> command.
>
> 2. I would like to not plot arrows but instead plot axes for the
> variables, as suggested by Gower & Hand (1996). Or, ideally, plot axis
> lines which extend on either side of the origin, as far as the maximum and
> minimum observed value for that variable.
>
> Damon Wischik.

One of the glories of R is that you're NOT limited to showing what's
already canned in custom plots.  However, it usually takes much more
work than a one-line command.  Build a matrix or data frame with the
x-y values for the points you want to show and use plot(), then many
calls to points(), lines(), text(), symbols(), axis(), title(), etc.
to build up the graphic display you want, piece by piece.  Tedious,
but it's totally flexible, and you get exactly the display you want.
And, with postscript(), the result looks absolutely great !  See the
help for each of the functions listed above, also for par() to change
the size or aspect ratio of the plot on the page.

I find it helpful to build up a script of plotting commands in a text
editor window, then run 'source("filename")' on each new version I've
saved.  My scripts the first time through use literal names for the
data objects in the workspace.  There's always time later to package
it up inside a function definition, and think then about what I would
want to be able to pass in as function arguments and what I'm willing
to leave wired into the code.  In practice, I almost never do this
polishing.  Instead, the  next time I'm doing such a problem, I grab
a few ideas from an old script and essentially start again.  That's
how I do it.  Maybe others have a much more elegant way.

-  tom blackwell  -  u michigan medical school  -  ann arbor  -



More information about the R-help mailing list