gaospecial / ggVennDiagram

A 'ggplot2' implement of Venn Diagram.
https://gaospecial.github.io/ggVennDiagram/
GNU General Public License v3.0
277 stars 37 forks source link

A short question #54

Closed DengEr-1993 closed 9 months ago

DengEr-1993 commented 1 year ago

Can't I use expression to change sets names ?

I need it but I tried my best it still doesn't work.

I want to change the sets labels, it works well. However, when I add expression in ggplot2 or VennDiagram,

error information always appeared.

Could you give me some advice ?

 geom_sf_text(aes(label = c("Set 1",
                             "Set 2")),fontface = "bold",data = venn_setlabel(data),size = 6) +

library("ggVennDiagram")
library(ggplot2)
venn <- Venn(x)
data <- process_data(venn)
personal_theme = theme(plot.title = element_text(hjust = 0.5))
?geom_sf
?geom_sf_label
?percent

ddd<-venn_setlabel(data)

p<-ggplot() +

  geom_sf(aes(fill = count,alpha=1), data = venn_region(data)) +

  #geom_sf(aes(color = "black",size=2), data = venn_setedge(data), show.legend = FALSE) +
  geom_sf(color="black", size = 20, data = venn_setedge(data), show.legend = FALSE) +

  geom_sf_text(aes(label = c("Set 1",
                             "Set 2")),fontface = "bold",data = venn_setlabel(data),size = 6) +

  geom_sf_text(aes(label = paste0(count, " \n(", scales::percent(count/sum(count), accuracy = 0.01), ")")), 
                data = venn_region(data),
                size = 6) +
  theme_void()+
  scale_fill_gradient(low = "#4981BF", high = "#21908dff") +
  theme(legend.position = "none")+
  theme(plot.title = element_text(size=22))
DengEr-1993 commented 1 year ago

I solved this problem. Thanks.