Subversion Repositories bdplot

Rev

Rev 57 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
55 pdel 1
### this is supposed to set all par vars so that plot or another plotting command can be used.
2
 
3
## example on purpose:
4
## bdopen()
5
## bdinit()
6
## boxplot(x)
7
## bddev.off()
8
 
9
 
10
## It's a mess to set cex.lab here. Or it should not be set in
11
##  functions calls. If set both ways, it's scaled twice, meaning that
12
##  we don't know how to make it fit with mtext for eg rlab.
13
 
14
bdinit <- function(){
15
 
16
##  par(cex.main=bdp()$cex.main, cex.lab=bdp()$cex.lab,
17
##      cex.axis=bdp()$cex.axis,cex=bdp()$cex.plot)
18
 
66 pdel 19
  par(##cex.plot=bdp()$cex.plot, 
20
      cex.main=bdp()$cex.main,
21
      cex.lab=bdp()$cex.lab,
22
      cex.axis=bdp()$cex.axis)
55 pdel 23
 
24
  par(tcl=bdp()$tcl)
25
  par(lwd=bdp()$lwd)
26
  par(bty=bdp()$bty)
27
 
28
 
29
  ##Set margins. If mar is set, then that should be used.
30
  if (!is.null(bdp()$mar)){
31
    print(bdp()$mar)
32
    mar <- bdp()$mar
33
  } else {
34
 
35
    detmar <- function(idx,lab){
36
      if (is.null(lab)) {
37
        mar <- bdp()$mar.lab[idx]
38
      } else if(all(is.na(lab))) {
39
        mar <- bdp()$mar.nolab[idx]
40
      } else {
41
        mar <- bdp()$mar.lab[idx]
42
      }
43
      return(mar)
44
    }
45
    mar <- c(detmar(1,bdp()$xlab),
46
             detmar(2,bdp()$ylab),
47
             detmar(3,bdp()$tlab),
48
             detmar(4,bdp()$rlab))
49
 
50
  }
51
  par(mar=mar)
52
 
53
  par(mgp=bdp()$mgp.global)
66 pdel 54
 
55
### could par(cex=cex.plot) also be done here?
55 pdel 56
 
57
}
58
 
66 pdel 59
## This is a dirty patch to make boxplots and hopefully histograms a
60
## lot better after initializing with binit.ext. bdinit should do this.
61
bdinit.ext <- function(){
62
  bdp(mgp.global=c(1.8,.5,0))
63
  bdp(mar.nolab=c(1.5,1,.8,.3))
64
  bdp(mar.lab=c(3,3,3,3))
65
 
66
  bdinit()
67
  par(cex.lab=1.5)
68
  par(cex.axis=1.5)
69
 
70
 
71
}