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]]

