Subversion Repositories bdplot

Rev

Rev 57 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

### this is supposed to set all par vars so that plot or another plotting command can be used.

## example on purpose:
## bdopen()
## bdinit()
## boxplot(x)
## bddev.off()

  
## It's a mess to set cex.lab here. Or it should not be set in
##  functions calls. If set both ways, it's scaled twice, meaning that
##  we don't know how to make it fit with mtext for eg rlab.

bdinit <- function(){

##  par(cex.main=bdp()$cex.main, cex.lab=bdp()$cex.lab,
##      cex.axis=bdp()$cex.axis,cex=bdp()$cex.plot)

  par(cex=bdp()$cex.plot)  
  
  par(tcl=bdp()$tcl)
  par(lwd=bdp()$lwd)
  par(bty=bdp()$bty)
  
  
  ##Set margins. If mar is set, then that should be used.
  if (!is.null(bdp()$mar)){
    print(bdp()$mar)
    mar <- bdp()$mar
  } else {
    
    detmar <- function(idx,lab){
      if (is.null(lab)) {
        mar <- bdp()$mar.lab[idx]
      } else if(all(is.na(lab))) {
        mar <- bdp()$mar.nolab[idx]
      } else {
        mar <- bdp()$mar.lab[idx]
      }
      return(mar)
    }
    mar <- c(detmar(1,bdp()$xlab),
             detmar(2,bdp()$ylab),
             detmar(3,bdp()$tlab),
             detmar(4,bdp()$rlab))
    
  }
  par(mar=mar)
  
  par(mgp=bdp()$mgp.global)
  
}