[R] Layout of two graphs on a page...

Kate Ignatius kate.ignatius at gmail.com
Sat Jun 21 17:49:46 CEST 2014


I'm trying to have a layout of two graphs on a page... this has worked
before... but I changed up the way I do my venn diagrams so now
instead of the Venn Diagram being at the bottom of the page below the
bar/line graph it takes up the whole page and its overlays the
bar/line graph placed on the top half...

Here is my code:

layout(matrix(c(1,2),2,1,byrow=TRUE),widths=c(1,1),heights=c(2,2))
oldmar <- par("mar")
par(oma=c(0,2,0,2),mar=c(5.1,4.1,4.1,3.1))

my_tcks<-pretty(c(0,max(counts)),6)

b <- barplot(counts,col='purple',axes=F,border=FALSE,cex.names = 0.75,
las=2, ylim=c(0,my_tcks[length(my_tcks)]))
axis(2,at=my_tcks, labels=format(my_tcks, scientific = FALSE),
cex.axis=0.75, las=2)
mtext("",side=2,line=4,cex=1)

par(new=TRUE)
barplot(rep(NA,4),ylim=c(0,(max(ratio)+1)),axes=FALSE)
axis(4, cex.axis=0.75, las=2)
mtext("",side=4,line=2,cex=1)
lines(b, ratio,col="black",lwd=2)

par(mar=oldmar)
par(new=FALSE)

library(VennDiagram)
draw.quad.venn(area1=area1,area2=area2,area3=area3,area4=area4,n12=n12,n13=n13,n14=n14,n23=n23,n24=n24,n34=n34,n123=n123,n124=n124,n134=n134,n234=n234,n1234=n1234,
              category=c(A,B,C,D),fill=c("white","white","white","white"),
              alpha=c(0.2,0.2,0.2,0.2), euler.d=FALSE, scaled=FALSE,
cex=2, cat.cex=1.5, main="")
dev.off()

I've changed around the oma and mar settings so much now that I'm a
tad confused and probably over looking something really obvious.

Thanks in advance...

P.S.  Let me know if more details are required (I can substitute some
numbers here if it helps plot some graphs)



More information about the R-help mailing list