[R] Re: gamma cannot be modified on this device

Robert Ahrens ahrens at zoology.ubc.ca
Tue May 10 07:19:31 CEST 2005


Problem:  dev.copy2eps results in gamma cannot be modified on this 
device.  File cannot be opened by Adobe Illistrator.  File can be 
converted by Adobe distiler.  Any help on fixing gamma error would be 
appreciated.


Code:  Utilizes PBS Mapping
plots<-function(){
    library(PBSmapping)
    par(mfrow=c(2,1))
    par(omi=c(.5,.5,.5,.5))
    par(mai=c(0,0.5,0.0,.7))
    par(ask=T)
    nm<-c("Albacore Tuna","Bigeye Tuna","Yellowfin 
Tuna","Swordfish","Blue Marlin","Striped Marlin","Black Marlin","White 
Marlin","Bluefin Tuna","Southern Bluefin Tuna")
    nm2<-c("ALB","BET","YFT","SWO","BUM","STM","BLM","WHM","BFT","SBT")
    data(indLLhigh)
    data(recoutglo30yr)
    dfile<-recoutglo30yr
    for(i in 1:levels(nm2)){
        fl<-dfile[dfile$Sp==nm2[i],]
        species<-nm[i]
        nrec=length(fl$X)
        Z<-vector(length=length(fl$X))
        for (j in 1:nrec){
            xx<-fl$X[j]
            if(xx<20){
                Z[j]=360+fl$X[j]
            }else{
                Z[j]=fl$X[j]
            }
        }
        fl$X<-Z
        makeplots(indLLhigh,fl,species,c(20,380),1)
        makeplots(indLLhigh,fl,species,c(20,380),2)
        outfile<-paste(nm2[i],"RN.eps","")
        dev.copy2eps(file=outfile)
    }
}
makeplots<-function(mfile,dfile,ttl,xl,zvariable){
    yl<-c(-70,80)
        if (zvariable==1) {
            tlabel<-paste(ttl,"Recruitment",sep=" ")
    } else {
            tlabel<-paste(ttl,"Numbers",sep=" ")
    }
    plotMap(mfile,col="tan",bg="transparent",xlim=xl,ylim=yl,
        main=tlabel,plt=NULL,type="n",projection="LL")
    mtext("(Thousands)",side=3,line=0.5,cex=0.7)
    
grid<-makeGrid(x=seq(xl[1],xl[2],5),y=seq(yl[1],yl[2],5),projection="LL")
    events<-dfile
        if (zvariable==1) {
            events$Z<-events$Rec
    } else {
            events$Z<-events$Ninit
    }
   
    locData<-findPolys(events,grid)
    pdata<-combineEvents(events,locData,FUN=mean)
    brksmax<-max(events$Z)
    brksmin<-min(events$Z)
    nbrks<-20
    brks<-seq(brksmin,brksmax,by=(brksmax-brksmin)/nbrks)
    #cols<-rev(grey(seq(0,1,by=1/nbrks)))
    cols=rev(rainbow(nbrks,start=0,end=0.6))
    cols[1]<-"darkblue"
    pdata<-makeProps(pdata,brks,"col",cols)
    addPolys(grid,polyProps=pdata,border=F)
    addPolys(mfile,col="tan")
    abline(h=0,lty="dashed",col="red")   
    abline(h=40,lty="dashed",col="red")   
    abline(h=-40,lty="dashed",col="red")
    ltext<-vector(length=length(brks))
    ltext<-NA
    
ltext[1]<-as.integer(brks[1]/1000);ltext[nbrks]<-as.integer(brks[nbrks]/1000);ltext[as.integer(nbrks/2)]<-as.integer(brks[as.integer(nbrks/2)]/1000)
    par(xpd=NA)
    
tmp<-legend(xl[2]+.1,yl[2]-.1,legend=rep("",nbrks),col=rev(cols),pch=15,pt.cex=1.2,bty="n",y.intersp=.45)
    text(tmp$rect$left+10,tmp$text$y,pos=4,rev(ltext),cex=.7)
    par(xpd=FALSE)
}

-- 
_____________________________
Robert Ahrens
Department of Zoology
University of British Columbia
6270 University Blvd.
Vancouver, B.C. V6T 1Z4
604.822.0046
ahrens at zoology.ubc.ca




More information about the R-help mailing list