3-х сторонняя диаграмма Венна с внутренними метками в R - PullRequest
0 голосов
/ 16 мая 2018

Я искал, чтобы выяснить, как можно построить диаграмму Венна с программным отображением внутренних меток (элементов перекрытия).В коде нет ошибки, но я все еще не могу понять, как это исправить.

Диаграмма Венна

  require(VennDiagram)

  AA <- c("hi","foo", "bar","yep","woo","hoo")
  BB <- c("baa","yep", "woo","yes")
  CC <- c("yes","foo","hi","woo", "huh")

  x <- list(AA=AA , BB=BB , CC=CC)


  v0 <- venn.diagram( x, filename=NULL)

  grid.draw(v0)

  overlaps <- calculate.overlap(x)
  #overlaps <- rev(overlaps)


  for (i in 1:length(overlaps)){
    v0[[i+6]]$label <- paste(overlaps[[i]], collapse = "\n") # labels start at position 7 in the list for Venn's with 3 circles
  }


  grid.newpage()
  grid.draw(v0)

enter image description here

1 Ответ

0 голосов
/ 16 мая 2018
require(VennDiagram)

AA <- c("hi","foo", "bar","yep","woo","hoo")
BB <- c("baa","yep", "woo","yes")
CC <- c("yes","foo","hi","woo", "huh")

x <- list(AA=AA , BB=BB , CC=CC)


v0 <- venn.diagram( x, filename=NULL, 
                    fill = c("red", "blue", "green"),
                    alpha = 0.50,
                    col = "transparent")

grid.draw(v0)

overlaps <- calculate.overlap(x)

# extract indexes of overlaps from list names
indx <- as.numeric(substr(names(overlaps),2,2))


# labels start at position 7 in the list for Venn's with 3 circles
for (i in 1:length(overlaps)){
  v0[[6 + indx[i] ]]$label <- paste(overlaps[[i]], collapse = "\n") 
}


grid.newpage()
grid.draw(v0)

enter image description here

...