Re: [R] Re creating Procrustes Plot in Lattice

From: Gavin Simpson <>
Date: Wed, 30 Jul 2008 17:37:10 +0100

On Wed, 2008-07-30 at 04:59 -0700, Andrewjohnclose wrote:
> Hi, I have been trying to create a function to generate a Procrustes plot,
> generated from package "vegan"
> in lattice.
> standard vegan code as follows
> library(vegan)
> pro=protest(P1, P8, permutations=4999,choices=1:4)
> plot(pro)
> Now, here is the code for the function that I have failed to get to work
> properly.
> panel.procrustes=function(x,y)
> }Pro=protest(x,y,permutations=4999,choices=1:4)
> Proplot=plot(Pro)
> }
> xyplot(P1[1:4]~P8[1:4],panel=panel.procrustes)
> I can generate an empty plot, but not much else - hope someone can help and
> point out the obvious!
> Kind regards
> Andrew

The obvious thing is that whole thing is wrong! ;-)

What's wrong with the standard plot?

You are trying to mix base (standard) graphics functions with grid/lattice graphics and this is not possible (well Ok there is package gridBase).

You'll have to start doing the plotting from scratch in panel.procrustes. You might get some ideas of how to do this by looking at the ordixyplot functions and panel functions in current vegan that implement lattice graphics plots for ordiplot objects. I'm not sufficiently familiar with Lattice yet to advise how to go about producing a panel function, but the basic elements are:

So you'll need the Lattice equivalents of abline and then work out how to pass the X, Yrot and rotation components to your panel function. This is the bit I'm not clear on but look at ordixyplot and panel.ordi for inspiration.

Give it a go, but if you get stuck then mail me back privately (note I am moving house at the weekend so I'm not going to get back to you any time real soon!) or post a message on the vegan development website:

and Jari may be able to help you - I might also chip in there once I unpack my belongings and get my head round how to pass this stuff around in lattice...


 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e]
 Gower Street, London          [w]
 UK. WC1E 6BT.                 [w]

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 30 Jul 2008 - 16:46:18 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 Wed 30 Jul 2008 - 20:34:10 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive