Lattices or lattices. The combination of several graphs differs from yscaling (log10 and does not transform)

I have several time series variables, some of the variables have rather large ranges. I want to make a one-page graph with several complex graphs of each variable, some of which are scaled along the log10 y axis. I am relatively new to the grid and could not figure out how to efficiently mix log10 scaling with unsigned axes and get a publication quality graph. If print.trellis is used, the graphs are not aligned, and filling requires some work, if c.trellis is used, the layout is good, but only y-scaling from only one graph is used. Any suggestions for an efficient solution where I can replicate c.trellis output using different y-scaling for each (original) object? Example below:

    require(lattice)
    require(latticeExtra)

    # make data.frame
    d.date <- as.POSIXct(c("2009-12-15",  "2010-01-15",  "2010-02-15",  "2010-03-15", "2010-04-15"))                   
    CO2dat <- c(100,200,1000,9000,2000)
    pHdat <- c(10,9,7,6,7)
    tmp <- data.frame(date=d.date ,CO2dat=CO2dat ,pHdat=pHdat)

   # make plots 
   plot1 <- xyplot(pHdat ~ date, data=tmp
   , ylim=c(5,11)
   , ylab="pHdat"
   , xlab="Date"
   , origin = 0, border = 0
   , scales=list(y=list(alternating=1))
   , panel = function(...){
     panel.xyarea(...)
     panel.xyplot(...)
     }
     )

     # make plot with log y scale
     plot2 <- xyplot(CO2dat ~ date, data=tmp
            , ylim=c(10,10^4)
            , ylab="CO2dat"
            , xlab="Date"
            , origin = 0, border = 0
            , scales=list(y=list(alternating=1,log=10))
                                 , yscale.components = yscale.components.log10ticks
            , panel = function(...){
              panel.xyarea(...)
              panel.xyplot(...)
              # plot CO2air uatm
              panel.abline(h=log10(390),col="blue",type="l",...)
            }
            )

      # plot individual figures using split
      print(plot2, split=c(1,1,1,2), more=TRUE)
      print(plot1, split=c(1,2,1,2), more=F)   

      # combine plots (more convenient)
      comb <- c(plot1, plot2, x.same=F, y.same=F, layout = c(1, 2))

      # plot  combined figure
      update(comb, ylab = c("pHdat","log10 CO2dat"))
+5
source
1

@joran, , , ; , , . , , , ; , , , x .

, , , @joran, , , split, plot.trellis. , c , . , .

mtheme <- standard.theme("pdf")
mtheme$layout.heights$bottom.padding <- -10
plot1b <- update(plot1, scales=list(y=list(alternating=1, at=5:10, labels=paste("    ",c(5:10)))))
plot2b <- update(plot2, par.settings=mtheme)
pdf(file="temp.pdf")
print(plot2b, split=c(1,1,1,2), more=TRUE)
print(plot1b, split=c(1,2,1,2), more=F)   

enter image description here

+1

All Articles