Subversion Repositories bdplot

Rev

Rev 57 | 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.plot=bdp()$cex.plot, 
      cex.main=bdp()$cex.main,
      cex.lab=bdp()$cex.lab,
      cex.axis=bdp()$cex.axis)
  
  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)

### could par(cex=cex.plot) also be done here?
  
}

## This is a dirty patch to make boxplots and hopefully histograms a
## lot better after initializing with binit.ext. bdinit should do this.
bdinit.ext <- function(){
  bdp(mgp.global=c(1.8,.5,0))
  bdp(mar.nolab=c(1.5,1,.8,.3))
  bdp(mar.lab=c(3,3,3,3))

  bdinit()
  par(cex.lab=1.5)
  par(cex.axis=1.5)


}