How to have a title in the R Vennerable Venn Diagram?

I can not find anything in the documentation here . Code

library("Vennerable") data(StemCell) Vstem <- Venn(StemCell) Vstem3 <- Vstem[, c("OCT4", "SOX2", "NANOG")] tl <- "masi" plot(Vstem3, doWeights = TRUE, type = "circles") 

I tried unsuccessfully

  • plot(..., main = tl)
  • plot(..., title = tl)
  • plot(...); title(tl)
  • plt <- plot(...); title(plt, tl)

fig. 1 Invalid output without header

enter image description here

R: 3.3.1
OS: Debian 8.5

+5
source share
1 answer

user20650 answer in the comments given here. Try (1-2) and choose what works best.

  • The plot method is based on a grid package, so the normal base position of R is suitable for adding a heading will not work. Considering the arguments args(Vennerable:::plotVenn) , there is no way to add a title, and it is useless that the graphs do not return a mesh object. Therefore, you can simply draw a title in the chart window with the following

     grid.text("masi", y=0.9, gp=gpar(col="red", cex=2)) 
  • As an alternative method, you can grab the coffin and then use grid.arrange to build the header

     gridExtra::grid.arrange(grid::grid.grabExpr(plot(Vstem3, doWeights = TRUE, type = "circles")), top="masi") 

The grid.arrange path adds the title as a separate coffin, and then they are arranged in two rows. Therefore, when you resize the graphics window, it still appears above the graph. This will not be true if you draw directly in the window (as in the first version). Note: you do not need to use gridExtra , you can do this in a grid.

fig. 1 Exit from (1), Figure 2 Exit from (2)

enter image description here enter image description here

I think that (1) might be better with larger settings, but now (2) is better.

+3
source

Source: https://habr.com/ru/post/1259744/


All Articles