Using layout
, I can easily create panels.
op <- par(no.readonly = TRUE)
layout(matrix(1:3, nrow=1), widths=c(.8, 1.1, .8))
plot(1:20, 1:20, pch=19, cex=2, col=colfunc(20))
plot(1:20, 1:20, pch=19, cex=2, col=colfunc(20))
plot(1:20, 1:20, pch=19, cex=2, col=colfunc(20))
par(op)
However, when creating a plot with miniplot inside, such as a gradient,
plotfun <- () {
colfunc <- colorRampPalette(c("red", "blue"))
plot(1:20, 1:20, pch=19, cex=2, col=colfunc(20))
fig. <- c(grconvertX(c(.5, 4.5), from="user", to="ndc"),
grconvertY(c(8, 19), from="user", to="ndc"))
op <- par(fig=fig., mar=c(1, 1, 1, 1)) ## removed the new=TRUE to no avail
plot.window(c(0, 1), c(0, 1))
rasterImage(as.raster(matrix(colfunc(20), ncol=1)), 0, 0, 1, 1)
lbsq <- seq.int(0, 1, l=5)
axis(4, at=lbsq, pos=1, labels=FALSE, col=0, col.ticks=1, tck=-.1)
mtext(lbsq, 4, .25, at=lbsq, las=2, cex=.6)
mtext('foo', 3, -.125, cex=.6, adj=.1, font=2)
par(op)
}
it leaves the layout
.
op <- par(no.readonly=TRUE)
layout(matrix(1:3, nrow=1), widths=c(.8, 1.1, .8))
plotfun()
plotfun()
plotfun()
par(op)
I’m aware that layout
is “totally incompatible with … par(mfrow)”. But I already tried par()
which also didn’t work. Anyway I need something like layout
since I have different widths. Any clues, how to do it?