Matrix, grid and margin
1
0
Entering edit mode
@nicolas-servant-1466
Last seen 23 months ago
France
Dear BioC, I try to do a simple plot based on a grid layout. The idea is just to split the layout in a 2x2 grid and plot in each pixel one Matrix. The point is that I do not want any margin. I try the following code, but it always remains some margins. Any experience on this question is welcome !! Thank you Nicolas ## Top panel lc <- 2 gd <- grid.layout(nrow = lc, ncol = lc, widths = unit(0.5, "npc"), heights = unit(0.5, "npc")) vp <- viewport(x=0.5, y=0.5, w=unit(1, "npc"), h=unit(1, "npc"), layout=gd) pushViewport(vp) grid.rect(gp=gpar(col="red")) ## Matrix plot vp <- pushViewport(viewport(x=0.5, y=0.5,w=unit(1, "npc"), h=unit(1, "npc"), layout.pos.row=1, layout.pos.col=1)) ## At this stage it sounds good ... no margin grid.rect(gp=gpar(col="blue")) ##levelplot of the Matrix M <- Matrix(rnorm(100), ncol=10) nopadding <-list(layout.heights = list(top.padding = 0, main.key.padding = 0, key.axis.padding = 0, axis.xlab.padding = 0, xlab.key.padding = 0, key.sub.padding = 0, bottom.padding = 0), layout.widths = list(left.padding = 0, key.ylab.padding = 0, ylab.axis.padding = 0, axis.key.padding = 0, right.padding = 0)) im<-image(M,colorkey=FALSE, lattice.options=list(par.settings = nopadding), contour=FALSE, scales=list(draw=FALSE), xlab=NULL, ylab=NULL, sub=NULL) print(im, vp=vp, newpage=FALSE) popViewport() > sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=fr_FR.UTF-8 LC_NUMERIC=C [3] LC_TIME=fr_FR.UTF-8 LC_COLLATE=fr_FR.UTF-8 [5] LC_MONETARY=fr_FR.UTF-8 LC_MESSAGES=fr_FR.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] grid stats graphics grDevices utils datasets methods [8] base other attached packages: [1] Matrix_1.0-12 lattice_0.20-15 [[alternative HTML version deleted]]
• 1.3k views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 1 hour ago
United States
Hi Nicolas, Grid graphics are not part of Bioconductor, that is a part of base R. So you need to ask your questions on R-help. Best, Jim On 7/12/2013 4:51 PM, Servant Nicolas wrote: > Dear BioC, > > I try to do a simple plot based on a grid layout. > The idea is just to split the layout in a 2x2 grid and plot in each pixel one Matrix. > The point is that I do not want any margin. > I try the following code, but it always remains some margins. > Any experience on this question is welcome !! > Thank you > Nicolas > > > ## Top panel > lc<- 2 > gd<- grid.layout(nrow = lc, ncol = lc, > widths = unit(0.5, "npc"), > heights = unit(0.5, "npc")) > vp<- viewport(x=0.5, y=0.5, w=unit(1, "npc"), h=unit(1, "npc"), layout=gd) > pushViewport(vp) > grid.rect(gp=gpar(col="red")) > > ## Matrix plot > vp<- pushViewport(viewport(x=0.5, y=0.5,w=unit(1, "npc"), h=unit(1, "npc"), layout.pos.row=1, layout.pos.col=1)) > ## At this stage it sounds good ... no margin > grid.rect(gp=gpar(col="blue")) > > ##levelplot of the Matrix > M<- Matrix(rnorm(100), ncol=10) > > nopadding<-list(layout.heights = list(top.padding = 0, > main.key.padding = 0, > key.axis.padding = 0, > axis.xlab.padding = 0, > xlab.key.padding = 0, > key.sub.padding = 0, > bottom.padding = 0), > layout.widths = list(left.padding = 0, > key.ylab.padding = 0, > ylab.axis.padding = 0, > axis.key.padding = 0, > right.padding = 0)) > > im<-image(M,colorkey=FALSE, > lattice.options=list(par.settings = nopadding), > contour=FALSE, scales=list(draw=FALSE), > xlab=NULL, ylab=NULL, sub=NULL) > print(im, vp=vp, newpage=FALSE) > > popViewport() > > >> sessionInfo() > R version 3.0.1 (2013-05-16) > Platform: x86_64-pc-linux-gnu (64-bit) > > locale: > [1] LC_CTYPE=fr_FR.UTF-8 LC_NUMERIC=C > [3] LC_TIME=fr_FR.UTF-8 LC_COLLATE=fr_FR.UTF-8 > [5] LC_MONETARY=fr_FR.UTF-8 LC_MESSAGES=fr_FR.UTF-8 > [7] LC_PAPER=C LC_NAME=C > [9] LC_ADDRESS=C LC_TELEPHONE=C > [11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C > > attached base packages: > [1] grid stats graphics grDevices utils datasets methods > [8] base > > other attached packages: > [1] Matrix_1.0-12 lattice_0.20-15 > > > [[alternative HTML version deleted]] > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor -- James W. MacDonald, M.S. Biostatistician University of Washington Environmental and Occupational Health Sciences 4225 Roosevelt Way NE, # 100 Seattle WA 98105-6099
ADD COMMENT

Login before adding your answer.

Traffic: 900 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