[R] plot/ layout/ overlay problem

Sam McClatchie s.mcclatchie at niwa.co.nz
Sun Oct 12 23:25:48 CEST 2003


System info:
Red Hat 9.0
R Version 1.7.0
ESS 5.1.21
Emacs 21.2.1
-------------------
Colleagues

I have a small problem with positioning overlays using layout.

  ## Purpose: to plot temperature and salinity profiles
   ## as a multipanel figure, and
   ## overlay the the mixed
   ## layer depths.

Here is the code skeleton:
   --------------------
   nf <- layout(matrix(c(1,2,3,4,5,6,7,8,9,10,11,
                         12,13,14,15,16,17,18,19,20,21,22),
                       2,11,byrow=TRUE))

   par.old <- par(mai=c(1,0.5,1,0))
   for (i in 1:22){
     ## plot temperature profiles (solid line)
     plot(...

     ## plot sigma t profiles (dashed line)
     par("new"=TRUE)
     plot( ...
   }

   ## overlay the mixed layer depths
   nf <- layout(matrix(c(1,2),
                       2,1,byrow=TRUE))

   par("new"=TRUE)
   test.x <- c(0,1,2,3,4,5,6,7,8,9,10,11)
   test.y <- c(90,100,110,200,200,250,300,350,330,370,330,370)
   plot(test.x,test.y, ylim=c(1000,0), xlim=c(0,11),type='b',
        axes=F,lty=3)

   par(par.old)
-----------------------
The problem is that the second overlay comes up in the bottom panel 
(where the last of the 22 panels ended).

The question is: how do I get the second overlay to start in the top 
panel where the first of the 22 panels began?

Best fishes

Sam
-- 
Sam McClatchie, Research scientist (fisheries acoustics))))))))))
NIWA (National Institute of Water & Atmospheric Research Ltd)
PO Box 14 901, Kilbirnie, Wellington, New Zealand
s.mcclatchie at niwa.cri.nz
Research home page <http://www.smcc.150m.com/>
                          /\
               >><xX(&>
                       /// \\\
                      //// \\\\
                     ///  <%)Xx><<
                    /////  \\\\\\
              ><(((@>
        ><(((%>     ..>><xX(?>O<?)Xx><<




More information about the R-help mailing list