-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Hi Dr. Moon,
I've found that the font size of the final graph is not changed even when I've changed cex value in the ORplot().
I've tried to change some of the internal ORplot.sub().
I wonder if you are interested in these changes.
I am very impressed by your great works.
Thanks.
ORplot.sub_cex0.6=function(result,type=1,xlab="",ylab="",show.OR=TRUE,show.CI=FALSE,
sig.level=1,cex=0.7,lwd=2,pch=18,col=NULL,...){
result = result[-1,]
result=result[result[[4]]<=sig.level,]
count=length(result[,1])
if(count<1) {
cat("No variable to be plotted found")
return(invisible())
}
if(is.null(col) | (length(col)!=2) ) {
if(type==3) {col1="salmon";col2="darkturquoise"}
else {col1="firebrick2";col2="dodgerblue3"}
} else {
col1=col[1];col2=col[2]
}
result=result[order(result[[1]],decreasing=TRUE),]
max=max(result[,-4],na.rm=T)+0.1
min=min(result[,-4],na.rm=T)
x=log10(result[,1])_5/log10(max)
x1=log10(result[,2])_5/log10(max)
x2=log10(result[,3])_5/log10(max)
opar<-par(no.readonly=TRUE)
if(show.CI) par(mar=c(5,8,4,8))
else par(mar=c(5,8,4,2))
if(xlab=="") xlab=ifelse(colnames(result)[1]=="OR","Odds Ratios","Harzard Ratios")
plot(result[,1],count:1,type="n",axes=FALSE,ylim=c(0.5,count+0.5),
xlim=c(log10(min)_5/log10(max),5),xlab="",ylab=ylab,...)
rect(par("usr")[1],par("usr")[3],par("usr")[2],par("usr")[4], border=FALSE,
col = "gray88")
abline(h=count:1,col="white",lwd=2)
abline(v=0,lty=2,col="darkgray",lwd=2)
range=seq(min,max,0.5)
range2=seq(min+0.25,max,0.5)
abline(v=log10(range2)_5/log10(max),col="white",lwd=1)
abline(v=log10(range)_5/log10(max),col="white",lwd=2)
yscale=par("usr")[3:4]
xscale=par("usr")[1:2]
text(x=log10(range)_5/log10(max),y=par("usr")[3],range,pos=1,cex=0.5,xpd=TRUE)
if(length(range2)<4) text(x=log10(range2)_5/log10(max),y=par("usr")[3],range2,pos=1,cex=0.4,xpd=TRUE)
text(y=count:1,par("usr")[1],labels=rownames(result),pos=2,cex=0.55,xpd=TRUE)
#text(x=5,y=par("usr")[3],xlab,pos=1,cex=1,xpd=TRUE)
text(x=mean(range(xscale)),y=par("usr")[3],xlab,pos=1,cex=.6,offset=2,xpd=TRUE)
p=c()
for(i in 1:count){
if(is.nan(result[i,4])) p[i]=result[i,1]
else if(result[i,4]<0.001) p[i]=paste(result[i,1],"",sep="")
else if(result[i,4]<0.01) p[i]=paste(result[i,1],"",sep="")
else if(result[i,4]<0.05) p[i]=paste(result[i,1],"",sep="")
else p[i]=result[i,1]
}
if(type<3){
segments(x1,count:1,x2,count:1,lty=1,
col=ifelse(x>0,col1,col2),lwd=lwd)
if(show.OR) text(x,count:1,p,pos=3, offset = 0.2,cex=0.5) ## This is to be changed... position...
if(type==2) {
segments(x1,(count:1)-0.1,x1,(count:1)+0.1,lty=1,
col=ifelse(x>0,col1,col2),lwd=lwd)
segments(x2,(count:1)-0.1,x2,(count:1)+0.1,lty=1,
col=ifelse(x>0,col1,col2),lwd=lwd)
points(x,count:1,col=ifelse(x>0,col1,col2),pch=pch,cex=cex)
} else{
points(x,count:1,col=ifelse(x>0,col1,col2),pch=pch,cex=cex)
}
}
else{
left=ifelse(x>0,0,x)
right=ifelse(x>0,x,0)
height=0.25
rect(left,(count:1)+height,right,(count:1)-height,
col=ifelse(x>0,col1,col2))
segments(x1,count:1,x2,count:1,lty=1,lwd=lwd)
if(show.OR) text(0,count:1,p,pos=ifelse(x>0,2,4),cex=0.9)
}
if(show.CI){
text(y=count:1,par("usr")[2],
paste(p," (",result[,2],"-",result[,3],")",sep=""),
pos=4,xpd=TRUE)
CI.title=paste(colnames(result)[1],"(95% C.I.)")
text(y=max(yscale),par("usr")[2],CI.title,pos=4,xpd=TRUE)
}
par(opar)
}