yanlinlin82 / ggvenn

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

Request: Option to use names instead of counts in circles #4

Closed rossellhayes closed 4 years ago

rossellhayes commented 4 years ago

Excellent package! I was wondering if you would consider an option to use text labels instead of counts inside the circles, allowing the package to be used to create "traditional" Venn diagrams, such as the first example from Wikipedia.

yanlinlin82 commented 4 years ago

Thank you very much for your interest and kind suggestion! I will check and consider it.

yanlinlin82 commented 4 years ago

I have committed a new version, which supports a show_elements option. Could you please help to try it?

Here goes a quick view of the new feature:

# for list
list(A=1:3,B=3:6) %>%
   ggvenn(show_elements=TRUE)

# for data frame
data.frame(id=LETTERS[1:4],
           A=c(TRUE,TRUE,FALSE,FALSE),
           B=c(FALSE,TRUE,TRUE,TRUE)) %>%
  ggvenn(show_elements="id")

# for ggplot style using
data.frame(id=LETTERS[1:4],
           A=c(TRUE,TRUE,FALSE,FALSE),
           B=c(FALSE,TRUE,TRUE,TRUE)) %>%
  ggplot() +
  geom_venn(aes(A=A,B=B,label=id)) +
  coord_fixed() +
  theme_void()
rossellhayes commented 4 years ago

This is excellent! It fulfills my use case perfectly, much appreciated!