Reputation: 7517
I'm wondering how to fit the BELOW 3 R plots into single screen using the matrix structure below?
Note: I have annoted the code but the best way is to run each plot to see how it looks.
Here is my R code:
m2 <- matrix( c( 0,2,2,2,2, 1,2,2,2,2, 1,2,2,2,2, 0,2,2,2,2 ), nrow=5, ncol=4) # matrix m2
m3 <- matrix( c( 0,2,2,2,2,0, 1,2,2,2,2,3, 1,2,2,2,2,3, 0,2,2,2,2,0), nrow=6, ncol=4) # matrix m3
TL <- T ## NOW TRUE
if(TL==T) {layout(m3)}else{layout(m2)} ## IF TL==T, split the screen according to *m3*
## Plot # 1: ###############################################
curve(dcauchy(x,0,1),-6,6,yaxt="n",bty="n",xaxs="i",xlab="GG",font.lab=2,lwd=2,col="cyan2",ylab = "")
## Plot #2: ###############################################
plot(1, 1, type = "n", xlim = c(0,1.5), ylim = c(.01, 3),log="y", bty="n", axes=F, xaxs="i",
xlab = "GGG", ylab=expression(paste(bold('BBB'))),font.lab=2,cex.lab=2)
axis(side=1, at = seq(0,1.5,.25),labels = c("0",".25",".5",".75","1","1.25","1.5"))
axis(side=2, at = c(.01, 1/30, 1/10, 1/3, 1, 3),labels = c("1/100", "1/30", "1/10", "1/3", "1", "3"),las=1)
axis(side=4,at = c(.01, 1/30, 1/10, 1/3, 1,3),labels = F)
axis(side=4,at = c(.01*1.8, (1/30)*1.7, (1/10)*1.8, (1/3)*1.7, 1*1.7), c("YES", "NO", "YES", "NO", "NO"),tick=F,las=1,font=2,
mgp=c(1.5,.3, 0),cex.axis=1.8)
## Plot #3: ###############################################
ci <- c(0.09253967, 0.48434172)
plot(1, 1, ty="n" ,ann=F, yaxt="n", bty="n", xlim=c(ci[1], ci[2]), ylim=c(0, 1), xaxt="n")
axis(side = 1, at = ci)
arrows(ci[1], .01, ci[2], .01, code=3, lwd=2, angle = 90, length = .08 )
mtext(side=1,"GGG",line=2.8, font=2, cex= 1.5)
Upvotes: 1
Views: 55
Reputation: 263381
Try specifying the heights and widths parameters to layout
: I got what might be close to your goal with:
png(height=11, width=8, units="in", res=72)
if( TL ) {layout(m3, widths=c(3, 2,2,3), heights=rep(1.2, ncol(m3)) )
}else{
layout(m2)}
#.... your code here
dev.off()
Still might need some tweaking of the margins or positioning of the mtext
since the extra large letters on the side seem to expand over the edge of the plotted regions.
Upvotes: 1