0

I am using the Vennerable package to draw Venn diagrams.

library(Vennerable)

A <- c("aa","ab","ac","a1")
B <- c("bb","ab","bc")
C <- c("ac","bc","cc","aa")
L <- list(A=A,B=B,C=C)
V <- Venn(L)

I am aware that I can manipulate the font size for the "elements" with

gp <- VennThemes(compute.Venn(V))
gp$FaceText <- lapply(gp$FaceText,function(x) {x$fontsize<-10; return(x)})
plot(V ,doWeights=FALSE,show=list(FaceText="elements"),gp=gp)

Unfortunately, the elements' label text is put into the sets without space or comma ("aaac" instead "aa, ac"). See graph below. Is there any way to change this?

Furthermore, how can I introduce a line break into the elements' labels if I have many items (more than just 2 as in the case below (aa ac)? I believe a function like

linebreak <- function(x,...){
  gsub('(.{1,15})(\\s|$)', '\\1\n', x)} 

could help. But how would I integrate it into the Vennerable plot code?

Unfortunately, there isn't any pertaining information in the documentation of the package. Many thanks. enter image description here

zoowalk
  • 2,018
  • 20
  • 33

1 Answers1

0

If you put "\n" in the names the line breaks appear in the text-labels:

L <- list('A\nB'=A,'B\nC'=B,'C\nD'=C)
V <- Venn(L)
gp <- VennThemes(compute.Venn(V))
gp$FaceText <- lapply(gp$FaceText,function(x) {x$fontsize<-10; return(x)})
plot(V ,doWeights=FALSE,show=list(FaceText="elements"),gp=gp)

I wasn't able to get your linebreak function to work the way I imagined you expected, but there was no testing suite for it.

IRTFM
  • 258,963
  • 21
  • 364
  • 487