Subversion Repositories bdplot

Rev

Rev 69 | Blame | Compare with Previous | Last modification | View Log | RSS feed


## so far, there's no end function, so should it just be called bdsharex?
bdsharex.start <- function(nplots,heights=NULL){
  if(is.null(heights)){
    heights <- rep(1,nplots)
  } else if(length(heights)!=nplots) {
    stop("If !is.null(heights), heights must be of length nplots.")
  }
  
  layout(1:(nplots+2), heights=c(lcm(0.1), heights, lcm(1)))
  ##  bdp(mar.lab=c(0,5,0.1,1),xaxt="n",las=1,mgp=c(3.5, 1, 0))

  ## Labels seem to be scaled. Need adjustment so that it is reset
  ## after bdsharex.end. This looks ok at least sometimes.
  if(is.null(bdp()$saved.cex.lab)){
    
    bdp(saved.cex.lab=bdp()$cex.lab)
    bdp(saved.cex.axis=bdp()$cex.axis)
    bdp(saved.cex.legend=bdp()$cex.legend)
    
    bdp(cex.lab=bdp()$cex.lab*1.3)
    bdp(cex.axis=bdp()$cex.axis*1.3)
    bdp(cex.legend = bdp()$cex.legend*1.3)
  }
  else {
    bdp(cex.lab=bdp()$saved.cex.lab*1.3)
    bdp(cex.axis=bdp()$saved.cex.axis*1.3)
    bdp(cex.legend = bdp()$saved.cex.legend*1.3)
  }
  
  
  bdp(mar.nolab=c(0,bdp()$mar.nolab[2],0,bdp()$mar.nolab[4]))
  bdp(mar.lab=c(0,bdp()$mar.lab[2],0,bdp()$mar.lab[4]))
  
  bdp(xaxt="n",las=1,mgp=c(3.5, 1, 0))
  bdplot(0, type="n", yaxt="n", bty="n", xlab="", ylab="")
  bdp(mar.nolab=c(0,bdp()$mar.nolab[2],0,bdp()$mar.nolab[4]))
}

bdsharex.end <- function(xlab=bdp()$xlab){
  mtext(xlab,1,line=1.5,cex=bdp()$cex.lab*par("cex"))
##  par(bty="n")
  oldbdp <- list()
  oldbdp$grid.h <- bdp()$grid.h
  oldbdp$grid.v <- bdp()$grid.v
  bdp(grid.v=NA)
  bdp(grid.h=NA)
  bdp(grid=FALSE)
  bdplot(1,1,type="n",xaxt="n",yaxt="n",bty="n",ylab="",rlab="")
  bdp(grid.h=oldbdp$grid.h,grid.v=oldbdp$grid.v)

  bdp(cex.lab=bdp()$saved.cex.lab)
  bdp(cex.axis=bdp()$saved.cex.axis)
  bdp(cex.legend=bdp()$saved.cex.legend)
}