yanlinlin82 / ggvenn

Venn Diagram by ggplot2, with really easy-to-use API.
Other
167 stars 25 forks source link

ggplot labels with linebreaks inn ggvenn venn diagram #9

Closed yanlinlin82 closed 4 years ago

yanlinlin82 commented 4 years ago

Thank Anders for posting this question: https://support.bioconductor.org/p/133731/

library(ggvenn)
d<-data.frame(id=paste(LETTERS[1:9]),
           A=c(TRUE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,FALSE,FALSE),
           B=c(FALSE,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE),
           C=c(FALSE,FALSE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE))

p<-ggplot(d) +
  geom_venn(aes(A=A,B=B,C=C,label=id)) +
  coord_fixed()
  theme_void()
p

In the above code, the label of each intersection is collapsed by comma (,). It would be better to allow customize it.

yanlinlin82 commented 4 years ago

Try:

ggplot(d) + geom_venn(aes(A=A,B=B,C=C,label=id), label_sep = "\n")

or

ggvenn(d, show_elements = "id",  label_sep = "\n")