Home > Software engineering >  What's the simplest way to add a rectangle or border around my venn diagram to represent the un
What's the simplest way to add a rectangle or border around my venn diagram to represent the un

Time:06-15

I'm using the ggplot2 and ggVennDiagram packages. I have two sets "A" and "B" that are colored in and have white space behind them. I'm wondering if there is an easy way to simply add a rectangular border around the sets similar to box() when plotting a graph in R.

CodePudding user response:

Taking an example from the ggVennDiagram help page, let's draw an example:

library(ggVennDiagram)

x <- list(A = 1:5, B = 2:7, C  =3:6, D = 4:9)

ggVennDiagram(x)

enter image description here

To add a box around this, note that since it is actually a ggplot with the panel border removed, we can just add it back in

ggVennDiagram(x)   theme(panel.border = element_rect(fill = NA),
                         plot.margin = margin(10, 10, 10, 10))

enter image description here

  • Related