Control barplot width.
1
0
Entering edit mode
Peter • 0
@peter-6856
Last seen 4.6 years ago
China

Dear expert,

I want to combine 4 figures in the same plot. Each bar plot is related to the image() plot. I want to bar width is extractly the same width as grid width in the image() plot. The up-barplot and the left-barplot. I have pasted my code to follow. How can I modify for this purpose? Or does anyone know existed Bioconductor package for this?

Thank you very much in advance.

#######################My example code###########################

datMat <- matrix(rep(1,100),nrow=10)
op=par(oma=c(1,1,1,1),mar=c(1,1,1,1),lwd = 0.2,cex=.5)
nf <- layout(matrix(c(0,1,0,2,3,4),2,3,byrow=TRUE), widths=c(1,6,1),
heights=c(1,3), respect=TRUE)
par(mar=c(3,0.5,3,0),mgp=c(0,1,-2.2))
barplot(seq(1,10),width=1,xlim=c(0,ncol(datMat)),xlab="",space=0,col="blue",border = "white" )
box("inner", lty="dotted", col="green")
box("outer", lty="solid", col="green")
par(mar=c(0,0,0,0),mgp=c(0,1,-1))
barplot(-seq(1,10),ylim=c(0,nrow(datMat)),width=1.025,horiz=TRUE,,axes = T,space=0,col="blue", border = "white" )
par(mar=c(1,0,0,0))
x.len=ncol(datMat)
y.len=nrow(datMat)
single.col= 'chartreuse4'
double.col= 'blue4'
triple.col= '#FFFF33'
four.col= '#FF7F00'
five.col= '#E41A1C'
colors=c('grey90',single.col, double.col,triple.col,four.col,five.col);
image(x=1:x.len, y=1:y.len, z=t(datMat), col = colors, breaks=c(-0.5,0.5 ,1.5 ,2.5 ,3.5 ,4.5 ,5.5), axes = FALSE, ann=F);
abline(h=seq(0.5,0.5+y.len),col='white',lwd=0.5);
abline(v=seq(0.5,0.5+x.len),col='white',lwd=0.5)
par(mar=c(0,0,0,0),mgp=c(0,1,0))
barplot(seq(1,10),ylim=c(0,nrow(datMat)),width=.5,horiz=TRUE,axes = FALSE, space=0,col="blue",border ="white" )
axis(side=1)

######################
sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)
locale:
[1] C/UTF-8/C/C/C/C
attached base packages:
[1] datasets  utils     stats     graphics  grDevices methods   base
other attached packages:
[1] xlsx_0.5.7                  xlsxjars_0.6.1
[3] rJava_0.9-6                 nutshell_2.0
[5] nutshell.audioscrobbler_1.0 nutshell.bbdb_1.0
[7] faraway_1.0.6               MASS_7.3-35
loaded via a namespace (and not attached):
[1] tools_3.1.1
Barplot width • 1.7k views
ADD COMMENT
1
Entering edit mode
@gordon-smyth
Last seen 1 hour ago
WEHI, Melbourne, Australia

This question would be better sent to the R-help mailing list, as it seems a purely technical question about image() and barplot(), which are not a Bioconductor functions.

ADD COMMENT

Login before adding your answer.

Traffic: 702 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6