Problems with VennDiagram?

前端 未结 2 1256
一整个雨季
一整个雨季 2021-01-01 03:14

I have used the recipe given here with a lot of success. However, for past few days this does not seem to work. My sessionInfo() looks as follows:



        
2条回答
  •  醉梦人生
    2021-01-01 04:12

    MattBagg's answer is excellent but for completeness, let me add how to save multiple venn diagrams in the same page - useful when comparing multiple conditions. Something like this: enter image description here This solution is a mash up-up of MattBagg's and nmel's answers wrapped in a pdf() function.

    # libraries
    library(VennDiagram)
    library(grid)
    library(gridBase)
    library(lattice)
    
    # create the diagrams
    temp1 <- venn.diagram(list(B = 1:1800, A = 1571:2020),
        fill = c("red", "green"), alpha = c(0.5, 0.5), cex = 1,cat.fontface = 2,
        lty =2, filename = NULL)
    temp2 <- venn.diagram(list(A = 1:1800, B = 1571:2020),
        fill = c("red", "green"), alpha = c(0.5, 0.5), cex = 1,cat.fontface = 2,
        lty =2, filename = NULL)    
    
    
    # start new page
    plot.new() 
    
    pdf("testpdf", width = 14, height = 7)
    # setup layout
    gl <- grid.layout(nrow=1, ncol=2)
    # grid.show.layout(gl)
    
    # setup viewports
    vp.1 <- viewport(layout.pos.col=1, layout.pos.row=1) 
    vp.2 <- viewport(layout.pos.col=2, layout.pos.row=1) 
    
    # init layout
    pushViewport(viewport(layout=gl))
    # access the first position
    pushViewport(vp.1)
    
    # start new base graphics in first viewport
    par(new=TRUE, fig=gridFIG())
    
    grid.draw(temp2)
    
    # done with the first viewport
    popViewport()
    
    # move to the next viewport
    pushViewport(vp.2)
    
      grid.draw(temp2)
    
    # done with this viewport
    popViewport(1)
    
    dev.off()
    

提交回复
热议问题