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

Jim Lemon jim at bitwrit.com.au
Sun Jun 22 01:52:58 CEST 2014


On Sat, 21 Jun 2014 11:49:46 AM Kate Ignatius wrote:
> 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=n
> 
13,n14=n14,n23=n23,n24=n24,n34=n34,n123=n123,n124=n124,n134=n134,n234=n234,n
> 1234=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.
> 
Hi Kate,
My guess is that the layout() command and the grid graphics used by 
draw.quad.venn are conflicting. I have an idea that inserting a 
grid.frame into the function may restrict the Venn diagram to a portion 
of the graphics device, but I haven't got the time at the moment to 
work out how to do this and it is an awful hack anyway. 

Jim



More information about the R-help mailing list