Subversion Repositories bdplot

Rev

Rev 57 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 57 Rev 66
1
### this is supposed to set all par vars so that plot or another plotting command can be used.
1
### this is supposed to set all par vars so that plot or another plotting command can be used.
2
 
2
 
3
## example on purpose:
3
## example on purpose:
4
## bdopen()
4
## bdopen()
5
## bdinit()
5
## bdinit()
6
## boxplot(x)
6
## boxplot(x)
7
## bddev.off()
7
## bddev.off()
8
 
8
 
9
  
9
  
10
## It's a mess to set cex.lab here. Or it should not be set in
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
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.
12
##  we don't know how to make it fit with mtext for eg rlab.
13
 
13
 
14
bdinit <- function(){
14
bdinit <- function(){
15
 
15
 
16
##  par(cex.main=bdp()$cex.main, cex.lab=bdp()$cex.lab,
16
##  par(cex.main=bdp()$cex.main, cex.lab=bdp()$cex.lab,
17
##      cex.axis=bdp()$cex.axis,cex=bdp()$cex.plot)
17
##      cex.axis=bdp()$cex.axis,cex=bdp()$cex.plot)
18
 
18
 
19
  par(cex=bdp()$cex.plot)  
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)
20
  
23
  
21
  par(tcl=bdp()$tcl)
24
  par(tcl=bdp()$tcl)
22
  par(lwd=bdp()$lwd)
25
  par(lwd=bdp()$lwd)
23
  par(bty=bdp()$bty)
26
  par(bty=bdp()$bty)
24
  
27
  
25
  
28
  
26
  ##Set margins. If mar is set, then that should be used.
29
  ##Set margins. If mar is set, then that should be used.
27
  if (!is.null(bdp()$mar)){
30
  if (!is.null(bdp()$mar)){
28
    print(bdp()$mar)
31
    print(bdp()$mar)
29
    mar <- bdp()$mar
32
    mar <- bdp()$mar
30
  } else {
33
  } else {
31
    
34
    
32
    detmar <- function(idx,lab){
35
    detmar <- function(idx,lab){
33
      if (is.null(lab)) {
36
      if (is.null(lab)) {
34
        mar <- bdp()$mar.lab[idx]
37
        mar <- bdp()$mar.lab[idx]
35
      } else if(all(is.na(lab))) {
38
      } else if(all(is.na(lab))) {
36
        mar <- bdp()$mar.nolab[idx]
39
        mar <- bdp()$mar.nolab[idx]
37
      } else {
40
      } else {
38
        mar <- bdp()$mar.lab[idx]
41
        mar <- bdp()$mar.lab[idx]
39
      }
42
      }
40
      return(mar)
43
      return(mar)
41
    }
44
    }
42
    mar <- c(detmar(1,bdp()$xlab),
45
    mar <- c(detmar(1,bdp()$xlab),
43
             detmar(2,bdp()$ylab),
46
             detmar(2,bdp()$ylab),
44
             detmar(3,bdp()$tlab),
47
             detmar(3,bdp()$tlab),
45
             detmar(4,bdp()$rlab))
48
             detmar(4,bdp()$rlab))
46
    
49
    
47
  }
50
  }
48
  par(mar=mar)
51
  par(mar=mar)
49
  
52
  
50
  par(mgp=bdp()$mgp.global)
53
  par(mgp=bdp()$mgp.global)
-
 
54
 
-
 
55
### could par(cex=cex.plot) also be done here?
51
  
56
  
52
}
57
}
53
 
58
 
-
 
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
}
54
 
72