5 |
pdel |
1 |
### bdopen
|
|
|
2 |
### Used to open a graphics driver with BDplot.
|
|
|
3 |
|
7 |
pdel |
4 |
### In both jpeg and X11, height and width are scaled to
|
|
|
5 |
### jpeg: get a decent resolution (can't get it working with the true distances...)
|
|
|
6 |
### X11: to get a nicer window on the screen.
|
|
|
7 |
### This hack is ugly. At least there should be a scaling factor in stead so that all measures are scaled (fonts, etc).
|
|
|
8 |
|
5 |
pdel |
9 |
bdopen <- function(file=bdp()$file,paper=bdp()$paper,mfrow=bdp()$mfrow)
|
|
|
10 |
{
|
|
|
11 |
.bdcalcsizes(paper=paper)
|
|
|
12 |
prm <- .bdgetpars()
|
|
|
13 |
if( !is.na(prm$file) )
|
|
|
14 |
{
|
|
|
15 |
## If figdir is supplied, prepending it to filename.
|
|
|
16 |
if(!is.null(prm$figdir)&!is.na(prm$figdir))
|
|
|
17 |
{
|
|
|
18 |
prm$file <- paste(prm$figdir,prm$file,sep="")
|
|
|
19 |
}
|
|
|
20 |
## determining device driver from filename
|
|
|
21 |
nchars <- nchar(prm$file)
|
|
|
22 |
|
|
|
23 |
if( any( substr(prm$file,nchars-2,nchars)==".ps",substr(prm$file,nchars-3,nchars)==".eps")){
|
|
|
24 |
m <- {
|
|
|
25 |
cat("B/D plotting writing to postscript file\n")
|
|
|
26 |
postscript(file=prm$file, width=prm$width, height=prm$height, paper="special", horizontal=FALSE, family = "Helvetica")
|
|
|
27 |
}
|
|
|
28 |
} else if ( substr(prm$file,nchars-3,nchars)==".pdf")
|
|
|
29 |
{
|
|
|
30 |
pdf(file=prm$file, width=prm$width, height=prm$height)
|
|
|
31 |
} else if (any(substr(prm$file,nchars-3,nchars)==".jpg", substr(prm$file,nchars-4,nchars)==".jpeg")) {
|
|
|
32 |
cat("Writing to jpeg file\n")
|
|
|
33 |
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")
|
|
|
34 |
## bitmap(file=prm$file,type="jpeg",width=prm$width,height=prm$height,units=prm$size.unit,res=prm$jpeg.res,pointsize=.3)
|
|
|
35 |
}
|
|
|
36 |
}
|
|
|
37 |
else {
|
|
|
38 |
## to X. Note that this doesn't work on win and osx.
|
7 |
pdel |
39 |
X11(height=prm$height*2,width=prm$width*2)
|
5 |
pdel |
40 |
}
|
|
|
41 |
|
|
|
42 |
par(mfrow=mfrow)
|
|
|
43 |
}
|