[R] trellis/ panel.superpose/ passing in superscripts/ groups

McClatchie, Sam (PIRSA-SARDI) mcclatchie.sam at saugov.sa.gov.au
Tue Mar 15 05:14:45 CET 2005


Background:
OS: Linux Mandrake 10.1
release: R 2.0.0
editor: GNU Emacs 21.3.2
front-end: ESS 5.2.3
---------------------------------

Colleagues

I'm plotting fish egg densities in temperature-salinity space (i.e. mean
temperature ~ mean salinity | fish egg densities) for two survey years.  The
bivariate plot is overlaid on a temperature ~ salinity plot (not means)
showing the distribution of water masses, so I can see the association of
the eggs with water masses.

It is all working, but I have had to replace a call to panel.superpose with
panel.xyplot to plot the two years with different symbols. The problem may
be related to one raised by Volker Franz
<http://maths.newcastle.edu.au/~rking/R/devel/02b/0993.html> that was
reported to be fixed. On the other hand, I may just be using panel.superpose
incorrectly. You can see that I've messed around with the groups variable to
try and get it working.

My code is as follows.

"sardine.egg.T.S.space.2001.and.2002.exp" <-
  function()
  {
    library(lattice)
                                        # trellis.device(postscript,
                                        #
file="../figures/sardine.egg.T.S.space.2001.and.2002.ps",
                                        #                horizontal=FALSE,
color=TRUE)
    
    year <- as.factor(rep(2001,  dim(mn.ts.e.2001)[1]))    
    year.2001 <- cbind(mn.ts.e.2001,year)
    year <- as.factor(rep(2002,  dim(mn.ts.e.2002)[1]))    
    year.2002 <- cbind(mn.ts.e.2002,year)    
    mn.ts.e.both <- rbind(year.2001, year.2002)
                                        #browser()
###trellis plot
    ##int <- matrix(c(0,5,6,10,11,20,21,40,41,80,81,160), ncol=2,
byrow=TRUE)
    int <- matrix(c(0,2,3,4,5,8,9,16,17,32,33,64), ncol=2, byrow=TRUE)
    egg.counts <- shingle(mn.ts.e.both$eggs2.Pilch.Eggs, intervals = int)
    larvae.counts <- shingle(mn.ts.e.both$eggs2.Pilch.Larv, intervals = int)
    
    out1 <- xyplot(mn.t ~  mn.s |  egg.counts,
                   data = mn.ts.e.both,
                                        #groups = year,
                   xlim = c(35,38), ylim = c(12,24),
                   xlab = "mean salinity", ylab = "mean temperature (deg.
C)",
                   main = "2001 and 2002 egg densities in
Temperature-Salinity space",
                   aspect = "xy",
                   jitter = T,
                   layout = c(1,6),
                   auto.key=TRUE,
                   panel = function(x, y, subscripts = c(2,3)){
                     panel.xyplot(data.2001$Salinity,
data.2001$Temperature.oC, 
                                  pch=".", col="yellow")
                     panel.xyplot(data.2002$Salinity,
data.2002$Temperature.oC, 
                                  pch=".", col="orange")
                     panel.text(37.8, 15, "Upwelling")
                     panel.text(37.8, 17.5, "Warm pool")
                     panel.text(37.8, 19.75, "Shelf break")
                     panel.text(37.8, 21.5, "Spencer Gulf")
                     panel.abline(h = c(16,19,20.5), v = 36.5, col="red",
lty=2)
                                          
                    
                     ##  panel.superpose(x,y,
                     ##                  subscripts=c(2,3),
                     ##                  groups = mn.ts.e.both$year,
                     ##                  cex=0.5)
                     ##auto.key = T
                     panel.xyplot(year.2001$mn.s,  year.2001$mn.t,
                                  col="cyan")
                     panel.xyplot(year.2002$mn.s,  year.2002$mn.t,
                                  col="purple")
                     
                   }
                   )

    print(out1)
                                        #   graphics.off()
    
  }


Any suggestions regarding how to get panel.superpose working would be
gratefully received. Sorry I cannot provide the data so the code is easily
used. Data are a bit large to paste into an email.

Sam
----
Sam McClatchie,
Biological oceanography 
South Australian Aquatic Sciences Centre
PO Box 120, Henley Beach 5022
Adelaide, South Australia
email <mcclatchie.sam at saugov.sa.gov.au>
Telephone: (61-8) 8207 5448
FAX: (61-8) 8200 2481
Research home page <http://www.members.iinet.net.au/~s.mcclatchie/>
  
                   /\
      ...>><xX(°> 
                //// \\\\
                   <°)Xx><<
              /////  \\\\\\
                        ><(((°> 
  >><(((°>   ...>><xX(°>O<°)Xx><<




More information about the R-help mailing list