Home > Blockchain >  Create venn diagrams in R with circles one inside another
Create venn diagrams in R with circles one inside another

Time:01-11

I want to create venn diagrams to emphasize that groups (circles) are completely located inside one another, i.e., there are no elements in the inner circles that are not simutanously in outer circles.

I've used ggvenn and arrived at these results:

colonias <- c("colônias")
possessoes <- c("possessões", colonias)
dominios <- c("domínios", possessoes, colonias)

ggvenn(tipologia_britanica,
       show_elements = T,
       label_sep = "\n",
       fill_color = brewer.pal(name="Dark2", n=3),
       fill_alpha = 0.6,
       stroke_size = 0.2,
       stroke_alpha = 0.2,
       set_name_size = 5,
       text_size = 5)

enter image description here

The result is tchnically correct because it show that "colonias" are common to all three groups and that "possessoes" are common to both "possessoes" and "dominios". But graphically I would like te groups to be completely inside one another to show that are no elements in "colonias" that are not common to all three, and in "possessoes" that are not common to "dominios". I'm not sure that ggvenn package is capable of plotting that.

CodePudding user response:

One way may use the package eulerr. However, your question isn't very clear so I let you play with the package

See the example below :

library(eulerr)

fit <- euler(c("A" = 10, "B" = 10, "A&B" = 8, "A&B&C"=3))

plot(fit,
     fills = list(fill = c("red", "steelblue4","green"), alpha = 0.5),
     labels = list(col = "black", font = 4),quantities = T)

enter image description here

CodePudding user response:

I don't think ggvenn allows a plot with this kind of relationship. However, it's not terribly difficult to draw it yourself with ggplot and geom_circle from ggforce

ggplot(data.frame(group = c("domínios", "possessões", "colônias"),
                  r = c(3, 2, 1)), 
       aes(x0 = 3 - r, y0 = 0, fill = factor(group, group)))  
  geom_circle(aes(r = r), alpha = 1)  
  geom_text(aes(x = c(0, 1, 2), y = c(2.3, 1.3, 0), label = group), 
            size = 8)  
  scale_fill_manual(values = c('#77bca2', '#e1926b', '#a09cc8'),
                    guide = 'none')  
  coord_equal()  
  theme_void() 

enter image description here

  • Related