5 |
pdel |
1 |
### bdopen
|
|
|
2 |
### Used to open a graphics driver with BDplot.
|
|
|
3 |
|
|
|
4 |
bdopen <- function(file=bdp()$file,paper=bdp()$paper,mfrow=bdp()$mfrow)
|
|
|
5 |
{
|
|
|
6 |
.bdcalcsizes(paper=paper)
|
|
|
7 |
prm <- .bdgetpars()
|
|
|
8 |
if( !is.na(prm$file) )
|
|
|
9 |
{
|
|
|
10 |
## If figdir is supplied, prepending it to filename.
|
|
|
11 |
if(!is.null(prm$figdir)&!is.na(prm$figdir))
|
|
|
12 |
{
|
|
|
13 |
prm$file <- paste(prm$figdir,prm$file,sep="")
|
|
|
14 |
}
|
|
|
15 |
## determining device driver from filename
|
|
|
16 |
nchars <- nchar(prm$file)
|
|
|
17 |
|
|
|
18 |
if( any( substr(prm$file,nchars-2,nchars)==".ps",substr(prm$file,nchars-3,nchars)==".eps")){
|
|
|
19 |
m <- {
|
|
|
20 |
cat("B/D plotting writing to postscript file\n")
|
|
|
21 |
postscript(file=prm$file, width=prm$width, height=prm$height, paper="special", horizontal=FALSE, family = "Helvetica")
|
|
|
22 |
}
|
|
|
23 |
} else if ( substr(prm$file,nchars-3,nchars)==".pdf")
|
|
|
24 |
{
|
|
|
25 |
pdf(file=prm$file, width=prm$width, height=prm$height)
|
|
|
26 |
} else if (any(substr(prm$file,nchars-3,nchars)==".jpg", substr(prm$file,nchars-4,nchars)==".jpeg")) {
|
|
|
27 |
cat("Writing to jpeg file\n")
|
|
|
28 |
jpeg(filename=prm$file,width=prm$width*2,height=prm$height*2,units=prm$size.unit,quality=prm$jpeg.quality,res=prm$jpeg.res,type="cairo")
|
|
|
29 |
## bitmap(file=prm$file,type="jpeg",width=prm$width,height=prm$height,units=prm$size.unit,res=prm$jpeg.res,pointsize=.3)
|
|
|
30 |
}
|
|
|
31 |
}
|
|
|
32 |
else {
|
|
|
33 |
## to X. Note that this doesn't work on win and osx.
|
|
|
34 |
x11()
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
par(mfrow=mfrow)
|
|
|
38 |
}
|