Open ghs101 opened 1 year ago
Hi @ghs101 ,
Thank you for submitting this issue. So far, the ggvenn
package does not implement this perfectly. I may try to improve it in the future.
If you are using a list
type of data, I am afraid that it can use only one stroke color now:
a <- list(A = 1:5, B = 4:7)
ggvenn(a, stroke_color = "red")
ggvenn(a, stroke_color = c("red", "blue")) # this gives error as you reported
A current workaround is using ggplot grammar (i.e. geom_venn
function) instead, which requires a data.frame
type of data:
d <- data.frame(A = c(TRUE, TRUE, FALSE), B = c(FALSE, TRUE, TRUE))
d %>% ggplot() + geom_venn(aes(A = A, B = B), stroke_color = c("red", "blue"))
For the list
type of data, a utility function list_to_data_frame()
may be helpful:
list_to_data_frame(a) %>% ggplot() + geom_venn(aes(A = A, B = B), stroke_color = c("red", "blue"))
Thanks for the workaround!
just letting you know the function list_to_dataframe doesn't seem to work
> library(ggvenn)
> list_to_data_frame(x)
Error in list_to_data_frame(x) :
could not find function "list_to_data_frame"
Sorry for the inconvenience. I just noticed that the function list_to_data_frame
(as well as data_frame_to_list
) is still in develop and has not been pushed to the release version. I will fix that later too.
Therefore, you may try to install the latest version from GitHub repository like this:
library(devtools)
devtools::install_github("yanlinlin82/ggvenn")
Otherwise, if you want to stay with the CRAN version, you can define the function yourself directly:
list_to_data_frame <- function(x) {
df <- tibble(key = unique(unlist(x)))
for (name in names(x)) df[, name] <- df$key %in% x[[name]]
return(df)
}
Hi,
Is it possible to give a different stroke colour to each circle just as the fill colour?
regards